云点播使用方法

具体可参考云点播官方文档
(1).在页面中引入文件
在合适的地方引入播放器样式文件与脚本文件:

<link href="https://imgcache.qq.com/open/qcloud/video/tcplayer/tcplayer.css" rel="stylesheet">
 <!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.v4.1.min.js 之前引入 hls.min.0.13.2m.js。-->
 <script src="https://imgcache.qq.com/open/qcloud/video/tcplayer/libs/hls.min.0.13.2m.js"></script>
 <!--播放器脚本文件-->
 <script src="https://imgcache.qq.com/open/qcloud/video/tcplayer/tcplayer.v4.1.min.js"></script>

如果在域名限制区域,可以引入以下链接:

<link href="https://cloudcache.tencent-cloud.com/open/qcloud/video/tcplayer/tcplayer.css" rel="stylesheet">
 <!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.v4.1.min.js 之前引入 hls.min.0.13.2m.js。-->
 <script src="https://cloudcache.tencent-cloud.com/open/qcloud/video/tcplayer/libs/hls.min.0.13.2m.js"></script>
 <!--播放器脚本文件-->
 <script src="https://cloudcache.tencent-cloud.com/open/qcloud/video/tcplayer/tcplayer.v4.1.min.js"></script>

暂不支持 VUE React 等框架的模块加载方式,可以通过 script 全局引入相关脚本的方式进行使用。

(2)放置播放器容器

<video id="player-container-id" width="414" height="270" preload="auto" playsinline webkit-playsinline>
</video>

(3)初始化:注意,这里需要加密,后台需返回相应参数

init(){
	const video = this.detail.video
    const params = {
    	business: this.business,
   		fileId: video.qcloud_file_id,
        url: video.qcloud_url,
    }
    const result = await QcloudUgcvideoWebview(params);  //此处为请求后台接口
    if (result.code === 0 && result.data) {
    	this.player = TCPlayer('player-container-id', {
        	fileID: video.qcloud_file_id, // 请传入需要播放的视频filID 必须
            appID: result.data.appId, // 请传入点播账号的appID 必须
            t: result.data.t,
            us: result.data.us,
            sign: result.data.sign,
         })
     }
}

(4)这里有个问题,如果我进入这个页面,初始化后,去其他页面,然后再进视频页面,初始化会有问题,所以离开页面的时候需要销毁掉video


      this.player.dispose()

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值