JavaScript Player API
cdn
https://vm.gtimg.cn/tencentvideo/txp/js/txplayer.js
http://vm.gtimg.cn/tencentvideo/txp/js/txplayer.js
API加载完成后会触发document的TxPlayerJSBrageReady
事件,然后就可以获取到播放器对象Txplayer
API Ready
$(document).on('TxPlayerJSBrageReady', function(){
var player = new Txplayer({vid: 'kidhsk03s12x'});
});
使用JSAPI >> demo
// 创建播放器
var player = new Txplayer({
containerId: 'container',
vid: 'r0018hmh1pa',
width: '100%',
height: screen.availHeight/3
});
// 调用api
player.pause(); // 暂停播放
player.mute(); // 视频静音
// 事件监听
player.on('ready', fn); // 初始化完成
player.on('volumeChange', fn); //音量发生变化
See the Pen 使用JSAPI by zoborzhang (@zoborzhang) on CodePen.