@@ -57,7 +57,7 @@
// importScripts('@/static/aliplayer/aliplayer-min.js')
export default {
props : [ "currentVideo" , "currentVideoList" , 'noRecored' ] ,
props : [ "currentVideo" , "currentVideoList" , 'noRecored' ] ,
data ( ) {
return {
// noRecored 为true时候不记录播放时长
@@ -77,7 +77,8 @@
isSetFirstTime : false ,
screenType : null ,
videoUrl : null ,
num : 0 ,
num : 0 ,
oprateOsName : ''
} ;
} ,
computed : {
@@ -90,11 +91,18 @@
} ,
} ,
// //页面显示
mounted ( ) {
mounted ( ) { this . getOS ( ) } ,
async beforeDestroy ( ) {
this . handleEnd ( ) ;
console . log ( "是否走啦习销毁" ) ;
clearInterval ( this . $store . state . videoTimer ) ;
clearInterval ( this . videoTimer ) ;
this . videoTimer = null ;
// store.commit("setLoadingShow", null);
plus . screen . lockOrientation ( "portrait-primary" ) ;
console . log ( "是否走啦习销毁定时器" , this . timer ) ;
await this . setVideoTime ( ) ;
} ,
async onUnload ( ) {
uni . navigateTo ( {
@@ -106,9 +114,9 @@
// plus.screen.lockOrientation("portrait-primary");
// #endif
this . timer = null ;
await this . setVideoTime ( ) ;
await this . setVideoTime ( ) ;
this . player . dispose ( ) ;
} ,
@@ -116,7 +124,7 @@
onLoad ( options ) {
console . log ( options , "这是传参" ) ;
// #ifdef APP-PLUS
setTimeout ( ( ) => {
plus . screen . unlockOrientation ( ) ;
plus . screen . lockOrientation ( "landscape-primary" ) ;
@@ -137,17 +145,21 @@
this . videoId = this . options . video ;
this . timer = setInterval ( ( ) => {
var that = this ;
if ( this . currentTime) {
that. setVideoTime( ) ;
}
} , 60000 ) ;
// this.timer = setInterval(() => {
// var that = this;
// if (this. currentTime) {
// that. setVideoTime();
// }
// }, 60000);
} ,
methods : {
// 获得操作系统
getOS ( ) {
this . oprateOsName = uni . getSystemInfoSync ( ) . platform ;
} ,
screenChange ( data ) {
console . log (
"status at line 这是当前的状态158:" ,
@@ -194,17 +206,17 @@
}
this . options = data . currentVideo ;
console . log ( "this.options at line 64:" , this . options ) ;
this . videoId = this . options . video ;
this . timer = setInterval ( async ( ) => {
var that = this ;
if ( this . currentTime) {
console. log ( '我是init定义的定时') ;
await that. setVideoTime( ) ;
}
} , 60000 ) ;
this . videoId = this . options . video ;
// this.timer = setInterval(async () => {
// var that = this;
// if (this. currentTime) {
// console.log( '我是init定义的定时');
// await that. setVideoTime();
// }
// }, 60000);
await this . getLive ( ) ;
} ,
async getData ( data ) {
async getData ( data ) {
if ( ! this . isSetFirstTime ) {
var netWork = this . videoData . userCourseVideoPositionEntity ?
this . videoData . userCourseVideoPositionEntity . position :
@@ -227,30 +239,35 @@
this . firstTime = 0 ;
}
}
// this.currentTime = this.firstTime;
console . log ( this . firstTime , "这是第一次播放时长222" , this . noRecored ) ;
await this . setVideoTime ( ) ;
this . currentTime = this . firstTime ;
console . log ( this . firstTime , "这是第一次播放时长222" , this . noRecored ) ;
await this . setVideoTime ( ) ;
uni . setStorageSync ( "videoOssList" , JSON . stringify ( list ) ) ;
console . log ( this . firstTime , "这是第一次播放时长" ) ;
this . isSetFirstTime = true ;
if ( this . currentVideo . type == 0 || this . currentVideo . type == 2 ) {
await this . playVideo ( ) ;
}
}
} ,
async playVideo ( e ) {
this . videoContext = uni . createVideoContext ( "videoId" , this ) ;
if ( this . isSetFirstTime ) {
this . isSetFirstTime = true ;
setTimeout ( ( res ) => {
this . videoContext. seek ( this . firstTime) ;
// this. videoContext.seek(this. firstTime);
// this.player.seek(this.firstTime);
this . setVideoFirtsetTime ( ) ;
} , 100 ) ;
// if (this.currentVideo.type == 0 || this.currentVideo.type == 2 ) {
// await this.playVideo();
// }
}
// this.videoContext.requestFullScreen();
} ,
// async playVideo(e) {
// this.videoContext = uni.createVideoContext("videoId", this);
// if (this.isSetFirstTime) {
// setTimeout((res) => {
// this.videoContext.seek(this.firstTime);
// this.setVideoFirtsetTime();
// }, 100);
// }
// // this.videoContext.requestFullScreen();
// },
recordTime ( data ) {
this . currentTime = data . time ;
@@ -275,7 +292,7 @@
uni . setStorageSync ( "videoOssList" , JSON . stringify ( list ) ) ;
console. log ( list , "走接口的方法参数") ;
// console.log(list, "走接口的方法参数");
} ,
// 获取数据
getLive ( ) {
@@ -295,7 +312,25 @@
} ,
} )
. then ( ( res ) => {
console . log ( 'res' , this . oprateOsName , res ) ;
if ( this . oprateOsName == 'ios' ) {
console . log ( '不符合播放条件' ) ;
if ( this . currentVideo . type == 1 && res . video . m3u8Url == null || this . currentVideo . type == 1 && res . video . m3u8Url == '' ) {
// 只存在私有加密
uni . showModal ( {
content : '抱歉,苹果手机不支持此加密视频格式,您可以在安卓端观看本视频' ,
confirmText : '知道了' ,
showCancel : false ,
success : function ( res ) {
if ( res . confirm ) {
uni . navigateBack ( { delta : 2 } )
}
}
} )
return
}
}
// if (this.currentVideo.type == 1 && res.video.m3u8Url == null || this.currentVideo.type == 1 && res.video.m3u8Url == '') {
if ( this . currentVideo . type == 1 ) {
var playAuth = res . video . playAuth . replace ( /=/g , "" ) ;
this . videoData = {
@@ -304,8 +339,21 @@
playAuth : playAuth ,
} ;
this . playAuth = playAuth ;
} else {
}
// else if(this.currentVideo.type == 1 && res.video.m3u8Url != null || this.currentVideo.type == 1 && res.video.m3u8Url != ''){
// this.videoData = {
// ...res.video,
// playAuth: new Date().getTime(),
// };
// this.videoUrl =
// res.video.m3u8Url;
// console.log('这是m3u8加密的视频');
// this.$nextTick(async () => {
// await this.getData();
// });
// }
else {
this . videoData = {
... res . video ,
playAuth : new Date ( ) . getTime ( )
@@ -313,7 +361,7 @@
this . videoUrl =
// "https://ehh-private-01.oss-cn-beijing.aliyuncs.com/video/taiHuClass/" +
res . video . videoUrl ;
console . log ( '这是常规视频' ) ;
console . log ( '这是常规视频' ) ;
// this.$nextTick(async () => {
// await this.getData();
// });
@@ -329,22 +377,22 @@
console . log ( 'this.currentTime at line 这是结束的时候掉的存储视频:' , this . currentTime )
clearInterval ( this . $store . state . videoTimer ) ;
this . timer = null ;
await this . setVideoTime ( ) ;
await this . setVideoTime ( ) ;
} ,
setVideoTime ( time ) {
let thisBlur = JSON . parse ( this . noRecored )
if ( thisBlur ) {
console . log ( '本条视频不记录播放记录,是未购买且试听章节' , thisBlur ) ;
if ( thisBlur ) {
console . log ( '本条视频不记录播放记录,是未购买且试听章节' , thisBlur ) ;
return
}
console . log ( '本条视频需要记录播放时长' , thisBlur ) ;
console . log ( '本条视频需要记录播放时长' , thisBlur ) ;
console . log ( "是否走了存储视屏," + this . videoData . id , this . currentTime , ) ;
var data = {
videoId : this . videoData . id ,
position : this . currentTime , //秒数
position : this . currentTime , // 秒数
} ;
return
console . log ( 'data-------' , data ) ;
$http
. request ( {
url : ` sociology/course/saveCoursePosition ` ,
@@ -358,6 +406,8 @@
. then ( ( res ) => {
console . log ( '存储视屏时长接口返回信息' , res )
this . $forceUpdate ( ) ;
} ) . catch ( e => {
console . log ( '存储进度接口报错' , e )
} ) ;
} ,
changePlayerTime ( player ) {
@@ -371,7 +421,7 @@
} ,
async setVideoFirtsetTime ( time ) {
this . currentTime = this . firstTime ;
console . log ( "这里准备开始设置播放时间:" , this . currentTime ) ;
console . log ( "这里准备开始设置播放时间:" , this . currentTime ) ;
store . commit (
"setVideoTimer" ,
setInterval ( async ( ) => {
@@ -415,6 +465,7 @@
player : null ,
curTime : null ,
curStatus : null ,
firstTime : null ,
// currentTime:null,
}
} ,
@@ -706,7 +757,8 @@
}
if ( this . videoData . type == 1 ) {
if ( this . videoData . type == 1 && this . videoData . m3u8Url == null || this . videoData . type == 1 && this
. videoData . m3u8Url == '' ) {
playerOptions = {
... playerOptions ,
"playauth" : this . videoData . playAuth , // 必选参数, 参数值可通过调用GetVideoPlayAuth接口获取。
@@ -715,12 +767,24 @@
"EncryptType" : 'AliyunVoDEncryption'
}
}
console . log ( '这是私有加密的视频' ) ;
} else if ( this . videoData . type == 1 && this . videoData . m3u8Url != null && this . videoData . type == 1 && this
. videoData . m3u8Url != '' ) {
playerOptions = {
... playerOptions ,
source : this . videoData . m3u8Url ,
playConfig : {
"EncryptType" : 'AliyunVoDEncryption'
}
}
console . log ( '这是标准加密的视频' ) ;
} else {
playerOptions = {
... playerOptions ,
source : this . videoData . videoUrl
}
console . log ( '这是没有加密的视频' ) ;
}
var player = new Aliplayer ( playerOptions , function ( player ) {
@@ -740,8 +804,14 @@
} , 1000 ) ;
// player.on('ready',function(){
// player.fullscreenService.requestFullScreen()
// // this.firstTime = 20
// console.log('播放器准备完毕',this.firstTime);
// // player.fullscreenService.requestFullScreen()
// if (this.firstTime > 0) {
// console.log('进入seek了吗? ',this.firstTime)
// player.seek(this.firstTime);
// }
// })
this . player . on ( 'ended' , function ( ) {
console . log ( 'that.curTime at line 242:' , this . curTime )
@@ -805,12 +875,12 @@
async receiveIsfresh ( newValue ) {
if ( newValue ) {
if ( this . player ) {
this . timer = null ;
await this . setVideoTime ( ) ;
this . timer = null ;
await this . setVideoTime ( ) ;
this . player . dispose ( ) ;
// this.player.seek( newValue);
this . player . seek ( newValue) ;
}
}
console . log ( 'newValue at line 427屏幕方向111111111111:' , newValue )
@@ -818,14 +888,15 @@
} ,
receiveFirstTime ( newValue , oldValue , ownerVm , vm ) {
// //数据变化
console . log ( 'newValue111' , newValue )
this . firstTime = newValue
console . log ( '第一次播放的值' , newValue , this . player )
console . log ( 'vm4444' , vm )
console . log ( 'this.firstTime at line 215:' , newValue )
if ( this . player ) {
this . player . seek ( newValue ) ;
}
// if (this.player) {
// console.log('进入seek了吗? ')
// this.player.seek(newValue);
// }
} ,