You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.8 KiB
JavaScript
104 lines
3.8 KiB
JavaScript
/// <reference path="../Scripts/MicrosoftAjax.js" />
|
|
/// <reference path="../Scripts/jquery.min.js" />
|
|
/// <reference path="../Scripts/swfobject.js" />
|
|
/// <reference path="../Scripts/jquery.bgiframe.min.js" />
|
|
|
|
|
|
MediaPlay = function () {
|
|
this.ApplicationPath = "";
|
|
this.ParentElement = null; //要加入的父容器
|
|
this.ControlID = "MediaPlay"; //控件ID
|
|
this.draggable = true;
|
|
|
|
var My = this;
|
|
var IsLoad = false;
|
|
var MediaFileName = "";
|
|
|
|
//#region 控件引用
|
|
var VideoID = "";
|
|
var ListVideoName = "";
|
|
//#endregion
|
|
//#region 加载
|
|
this.Load = function () {
|
|
if (IsLoad == true) { Play(); return; }
|
|
if (My.ParentElement == null) My.ParentElement = $(document.body);
|
|
VideoID = My.ControlID + "_VideoID"; //分组名称
|
|
ListVideoName = My.ControlID + "_ListVideoName"; //分组名称
|
|
Init();
|
|
IsLoad = true;
|
|
}
|
|
//#endregion
|
|
//#region 初始化
|
|
function Init() {
|
|
var htmlString = new Sys.StringBuilder();
|
|
htmlString.append("<div id='" + My.ControlID + "' title='视频' class='easyui-window' style='text-align: left; width: 630px; height: 360px;' shadow=false closed='true' modal='false' collapsible='false' minimizable='false' maximizable='true' closable='true' resizable='false' draggable='" + My.draggable + "'>");
|
|
htmlString.append("<div id='" + VideoID + "'></div>");
|
|
htmlString.append("</div>");
|
|
My.ParentElement.append(htmlString.toString());
|
|
$("#" + My.ControlID, My.ParentElement).window({
|
|
onMaximize: function () {
|
|
var width = $("#" + My.ControlID, My.ParentElement).innerWidth();
|
|
var height = $("#" + My.ControlID, My.ParentElement).innerHeight() - 20;
|
|
eval(VideoID + ".VideoResize(" + width + "," + height + ")");
|
|
$("#" + VideoID, My.ParentElement).attr("width", width).attr("height", height);
|
|
// $("#" + VideoID, My.ParentElement).css({ 'width': width, 'height': height });
|
|
},
|
|
onRestore: function () {
|
|
eval(VideoID + ".VideoResize(480,320)");
|
|
$("#" + VideoID, My.ParentElement).attr("width", "480").attr("height", "320");
|
|
},
|
|
onBeforeClose: function () {
|
|
Stop();
|
|
}
|
|
});
|
|
|
|
var swfVersionStr = "9.0.0";
|
|
var xiSwfUrlStr = My.ApplicationPath + "Scripts/playerProductInstall.swf";
|
|
var flashvars = {};
|
|
flashvars.videoUrl = My.ApplicationPath + MediaFileName;
|
|
flashvars.videoWidth = "480";
|
|
flashvars.videoHeight = "320";
|
|
flashvars.autoPlay = true;
|
|
var params = {};
|
|
params.quality = "high";
|
|
params.bgcolor = "#ffffff";
|
|
params.allowscriptaccess = "sameDomain";
|
|
params.allowfullscreen = "true";
|
|
var attributes = {};
|
|
attributes.id = VideoID;
|
|
// attributes.name = "${application}";
|
|
attributes.align = "middle";
|
|
swfobject.embedSWF(
|
|
My.ApplicationPath + "Scripts/MediaPlay.swf", VideoID,
|
|
"480", "320",
|
|
swfVersionStr, xiSwfUrlStr,
|
|
flashvars, params, attributes);
|
|
|
|
}
|
|
//#endregion
|
|
//#region 显示
|
|
this.Show = function (VideoName) {
|
|
if (VideoName == "") { alert("视频文件不能为空"); return; }
|
|
MediaFileName = VideoName;
|
|
My.Load();
|
|
$("#" + My.ControlID, My.ParentElement).window("open");
|
|
}
|
|
//#endregion
|
|
|
|
//#region 播放
|
|
function Play() {
|
|
eval(VideoID + ".PlayStart('" +My.ApplicationPath + MediaFileName + "')");
|
|
}
|
|
//#endregion
|
|
//#region 停止播放
|
|
function Stop() {
|
|
try {
|
|
eval(VideoID + ".PlayStop()");
|
|
} catch (e) {
|
|
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
|
|
} |