version 1.0
首先引入<script language="javascript" src="http://qzs.qq.com/tencentvideo_v1/js/tvp/tvp.player.js" charset="utf-8"></script>
<script>
var video = new tvp.VideoInfo(); //初始化視頻對(duì)象
video.setVid(vid); //向視頻對(duì)象傳入視頻vid 单寂,這個(gè)是點(diǎn)播的時(shí)候使用
//video.setChannelId(cnlid); //向視頻對(duì)象傳入直播頻道cnlid ,這個(gè)是直播的時(shí)候使用
/*點(diǎn)播跟直播的區(qū)別主要是:
點(diǎn)播是通過video.setVid(vid);
而直播是通過video.setChannelId(cnlid); 設(shè)置直播id
點(diǎn)播需要player.addParam('type','2');或者省略秋冰,因?yàn)槟J(rèn)播放器為點(diǎn)播狀態(tài);
直播必須通過player.addParam('type','1');設(shè)置播放器為直播狀態(tài)朝氓,梯码。
*/
var player = new tvp.Player(width, height); //初始化播放器對(duì)象并設(shè)置寬宁玫、高
player.setCurVideo(video); //設(shè)置播放器初始化時(shí)加載的視頻
player.addParam('type','1'); //設(shè)置播放器為直播狀態(tài)固惯,1表示直播,2表示點(diǎn)播洛心,默認(rèn)為2
player.addParam("wmode","transparent"); //設(shè)置透明化固耘,不設(shè)置時(shí),視頻為最高級(jí)皂甘,總是處于頁面的最上面玻驻,此時(shí)設(shè)置z-index無效
player.addParam('autoplay',false); //是否自動(dòng)播放
player.addParam('pic',''); //播放器默認(rèn)圖悼凑,當(dāng)autoplay=0時(shí)有效偿枕;不傳入則使用視頻截圖
player.addParam('showend',0) //結(jié)束時(shí)是否有廣告
player.addParam("flashskin", "http://imgcache.qq.com/minivideo_v1/vd/res/skins/TencentPlayerMiniSkin.swf"); //flash播放器精簡皮膚;不傳入則使用默認(rèn)皮膚
player.addParam("loadingswf", "http://imgcache.qq.com/minivideo_v1/vd/res/skins/web_small_loading.swf"); //加載視頻時(shí)的swf動(dòng)畫; 不傳入則使用默認(rèn)樣式
player.write(DOMid); //輸出播放器
//events
player.onplaying = function(vid) {
console.log(vid);
}
player.onended = function(vid) {
console.log(vid);
}
</script>
version 2.0
首先引入<script language="javascript" src="http://imgcache.qq.com/tencentvideo_v1/tvp/js/tvp.player_v2.js" charset="utf-8"></script>
<script>
var video = new tvp.VideoInfo();
video.setVid(vid);
var player =new tvp.Player();
player.create({
width: width, //播放器的寬度
height: height, //播放器的高度
video: video, //默認(rèn)的視頻對(duì)象
modId: DOMid, //默認(rèn)的 DOM 元素 ID
autoplay: false,
pic: imgURL
});
player.onplaying = function (vid){
console.log(vid)
}
player.onallended = function (vid){
console.log(vid)
};
</script>
查看更多方法和參數(shù)
最后編輯于 :2017.12.06 16:45:22
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者