js面向对象开发互联网机顶盒应用头端之一
/**
* Dare mediaplayer Object.
* @constructor
*/
//声明构造函数 构造函数初始化变量
Dare.MediaPlayer = function () {
this.parent = new Dare.Util();
this.className = "Dare.MediaPlayer";
//----类Dare.MediaPlayer全局属性变量-----//
this.playPath = ''; //媒体播放路径
this.playType = 0; //媒体类型 movie、music、pic
this.playMode = 0; //播放状态 停止、播放、暂停、快进、快退
this.playOrderMode = 1; //播放遍历模式
this.playAudioMode = 2; //播放音频输出模式
this.playCaptionMode = 0; //播放字幕输出模式
this.playTotalTime = 0; //媒体播放总时间 单位:秒
this.playTime = 0; //当前播放时间 单位:秒
this.playPercent = 0; //当前进度0--100
this.playVolume = 50; //当前播放音量
this.playWidth = 0; //媒体宽度
this.playHeight = 0; //媒体高度
this.playPointX = 0; //媒体X坐标
this.playPointY = 0; //媒体Y坐标
this.playSpeedMode = 0; //媒体快进快退模式 2、4、8、16、32
this.playMuteMode = 0; //静音模式:有声1、无声0
this.playScreenMode = 0; //0常规;1全屏
//----类Dare.MediaPlayer全局属性变量-----//
};
Dare.MediaPlayer.prototype = new Dare.Util(); //继承父类 Dare.Util是系统架构工具类
Dare.MediaPlayer.prototype.constructor = Dare.MediaPlayer; //引用构造函数
/**
* @function mediaPlayerInit
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.Init = function () { };
/**
* @function toJson
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.toJson = function () {
var str = '{playPath:"' + this.playPath
+ '",playType:' + this.playType + ','
+ 'playMode:' + this.playMode + ','
+ 'playTotalTime:' + this.playTotalTime + ','
+ 'playTime:' + this.playTime + ','
+ 'playVolume:' + this.playVolume + ','
+ 'playWidth:' + this.playWidth + ','
+ 'playHeight:' + this.playHeight + ','
+ 'playPointX:' + this.playPointX + ','
+ 'playPointY:' + this.playPointY + ','
+ 'playScreenMode:' + this.playScreenMode + ','
+ 'playMuteMode:' + this.playMuteMode + ','
+ 'playOrderMode:' + this.playOrderMode + ','
+ 'playAudioMode:' + this.playAudioMode + ','
+ 'playMuteMode:' + this.playMuteMode + ','
+ 'playPercent:' + this.playPercent + ','
+ 'playSpeedMode:' + this.playSpeedMode + '}';
var json = new Dare.JSObject.JSON();
return json.toObject(str);
};
Dare.MediaPlayer.prototype.fromJson = function (str) {
var job = new Dare.JSObject.JSON();
var json = job.toObject(str);
this.playPath = json.playPath;
this.playType = json.playType;
this.playMode = json.playMode;
this.playTotalTime = json.playTotalTime;
this.playTime = json.playTime;
this.playVolume = json.playVolume;
this.playWidth = json.playWidth;
this.playHeight = json.playHeight;
this.playPointX = json.playPointX;
this.playPointY = json.playPointY;
this.playScreenMode = json.playScreenMode;
this.playMuteMode = json.playMuteMode;
this.playOrderMode = json.playOrderMode;
this.playAudioMode = json.playAudioMode;
this.playMuteMode = json.playMuteMode;
this.playPercent = json.playPercent;
this.playSpeedMode = json.playSpeedMode;
}
/**
* @function getPlayTotalTime
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.getPlayTotalTime = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.Duration");
}
return str;
};
/**
* @function getPlayTime
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.getPlayTime = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.PlayProcess");
}
return str;
};
/**
* @function getVolume 获取音量
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.getVolume = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.GetVolume");
}
return str;
};
/**
* @function setVolume 设置音量
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.setVolume = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.SetVolume", '' + this.playType + "," + '' + this.playVolume);
}
};
/**
* @function setMute //设置静音
* @param
* @return null
*/
Dare.MediaPlayer.prototype.setMute = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.SetMute", '' + this.playType + "," + '' + this.playMuteMode);
}
};
/**
* @function getMute //获取静音
* @param
* @return null
*/
Dare.MediaPlayer.prototype.getMute = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.GetMute");
}
return str;
};
/**
* @function start 启动
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.start = function () {
//this.$('divDebug').innerHTML+=this.playType+' '+this.playPath;
if (Dare.isiPanel) {
//this.$('divDebug').innerHTML+=this.playType+' 55555555 '+this.playPath;
//alert(this.playPath);
iPanel.ioctlWrite("Media.Open", '' + this.playType + "," + this.playPath);
return iPanel.ioctlRead("Media.stopIfUsbRemove");
}
};
/**
* @function getPosition //获取媒体显示
* @param x, y, w, h
* @return null
*/
Dare.MediaPlayer.prototype.getPosition = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.Position");
}
return str;
};
/**
* @function setPosition //设置媒体显示 x, y, w, h
* @param x, y, w, h
* @return null
*/
Dare.MediaPlayer.prototype.setPosition = function () {
if (Dare.isiPanel) {
var position = this.playPointX + "," + this.playPointY + "," + this.playWidth + "," + this.playHeight + "," + '' + this.playType;
iPanel.ioctlWrite("Media.Position", position);
}
};
/**
* @function pause //暂停
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.pause = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Pause", '' + this.playType + "," + this.playPath);
}
};
/**
* @function resume //播放
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.resume = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Resume", '' + this.playType + "," + this.playPath);
}
};
/**
* @function playPrevious //播放上一个
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.playPrevious = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.PlayPrevious", this.playPath);
}
};
/**
* @function playNext //播放下一个
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.playNext = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.PlayNext", this.playPath);
}
};
/**
* @function setPlayMode //设置播放模式 停止、播放、暂停、快进、快退
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.setPlayMode = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.PlayMode", '' + this.playType + "," + '' + this.playMode);
}
};
/**
* @function getPlayMode //获取播放模式
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.getPlayMode = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.PlayMode");
}
return str;
};
/**
* @function setDisplayMode //设置显示模式
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.setDisplayMode = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.DisplayMode", '' + this.playType + "," + '' + this.playScreenMode);
}
};
/**
* @function getDisplayMode //获取显示模式
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.getDisplayMode = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.DisplayMode");
}
return str;
};
/**
* 是否停止
*/
Dare.MediaPlayer.prototype.isStop = function () {
var str = new String();
if (Dare.isiPanel) {
str = iPanel.ioctlRead("Media.isStop");
}
return str;
};
/**
* @function seek //定位
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.seek = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Seek", '' + this.playType + "," + this.secondsToHHMMSS(this.playTime));
}
};
/**
* @function seekpercent //定位percent 10 20 30 --90
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.seekPercent = function (percent) {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.seekPercent", '' + this.playType + "," + percent);
}
};
/**
* @function stop //停止
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.stop = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Stop", '' + this.playType + "," + this.playPath);
}
};
/**
* @function stopIfUsbRemove //判断此媒体所在usb是否被拔除,是则停止播放
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.stopIfUsbRemove = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.stopIfUsbRemove", '' + this.playType + "," + this.playPath);
return iPanel.ioctlRead("Media.stopIfUsbRemove");
}
};
/**
* @function append //追加播放列表
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.append = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Append", "append");
var json = new Dare.JSObject.JSON();
var jo = this.toJson();
iPanel.setGlobalVar("currentPlayMedia", json.parse(jo));
}
};
/**
* @function play //播放
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.play = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Play", '' + this.playType + ",play");
}
};
/**
* @function playBreak//播放中断 停止播放媒体源,同时记忆 hh:mm:ss 断点,用户作
系统设置等操作,然后再跳转回来继续正常播放;指令break
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.playBreak = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.playBreak", '' + this.playType + ",playBreak");
iPanel.setGlobalVar("currentPlayMedia", this.toJson());
}
};
/**
* 跳转回来继续正常播放
*/
Dare.MediaPlayer.prototype.playResume = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.playResume", '' + this.playType + ",playResume");
}
};
/**
* @function fastForward //快进
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.fastForward = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Forward", '' + this.playType + "," + '' + this.playSpeedMode);
}
};
/**
* @function fastRewind //快退
* @param null
* @return null
*/
Dare.MediaPlayer.prototype.fastRewind = function () {
if (Dare.isiPanel) {
iPanel.ioctlWrite("Media.Rewind", '' + this.playType + "," + '' + this.playSpeedMode);
}
};
邮箱:steven9801@163.com
QQ: 48039387