|
- const {file_id, vodAppId} = this.state.currentPlayVideoInfo
- let dhrVideo = api.require("TCSuperPlayer")
- let topX = 44 + Number(this.state.safe.safeAreaTop) // 顶部安全距离
- let screenWidth = api.screenWidth // 屏幕宽度
- dhrVideo.initPlayer()
- dhrVideo.resizePlayerView({
- rect:{
- x:0,
- y:topX,
- w:screenWidth,
- h:200,
- fixed: true
- }
- })
- dhrVideo.playWithTCloud({
- title: this.state.currentPlayVideoInfo.chapterName,
- appId: vodAppId,
- fileId: file_id
- })
- dhrVideo.setStartTime({
- setStartTime: this.state.currentPlayVideoInfo.watchTime
- })
- this.handleRecordTime();
- this.sendVideoPlayTime();
- // 播放器监听事件
- dhrVideo.addPlayerListener( (ret) => {
- console.log('视频播放状态监听', JSON.stringify(ret))
- if (ret.eventType === 'back') {
- dhrVideo.resizePlayerView({
- rect:{
- x:0,
- y:topX,
- w:screenWidth,
- h:200,
- fixed: true
- }
- })
- dhrVideo.showPlayerView()
- } else if (ret.eventType === 'didStart') {
- // 开始播放
- this.monitorTCVideoPlayState() // 定时获取播放状态
- this.timingGetPlayTime() // 定时获取播放时间
- } else if (ret.eventType === 'didEnd') {
- // 播放结束
- clearInterval(this.state.videoCurrentPlayTimer) // 清除播放时间定时器
- clearInterval(this.state.getVideoStateTimer) // 清除获取视频状态定时器
- let currentIndex = 0;
- let currentRemoteChapterId = this.state.currentPlayVideoInfo.remoteChapterId;
- this.state.courseChapter.forEach((item, index) => {
- if (currentRemoteChapterId === item.remoteChapterId) {
- currentIndex = index;
- }
- });
- console.log('播放结束', JSON.stringify(this.state.courseChapter))
- // this.changePlayData(this.state.courseChapter[currentIndex + 1])
- }
- })
复制代码 |
|