增加生命生命周期销毁

This commit is contained in:
zhouliujun 2019-12-13 10:13:12 +08:00
parent c702922880
commit a6b33d7559

View File

@ -188,16 +188,16 @@ export default {
// }); // });
if(!this.player){ if(!this.player){
// console.log(this.config); // console.log(this.config);
this.player = new Aliplayer(this.config); this.player = Aliplayer(this.config);
for(const ev in this.events){ for(const ev in this.events){
this.player.on(this.events[ev],(e)=>{ this.player && this.player.on(this.events[ev],(e)=>{
// console.log(`object ${this.events[ev]}`,e); // console.log(`object ${this.events[ev]}`,e);
this.$emit(this.events[ev],e); this.$emit(this.events[ev],e);
}); });
} }
} else { } else {
this.player.replay(); // this.player && this.player.replay(); //
// console.log(`this.player.replay()`,''); // console.log(`this.player && this.player.replay()`,'');
} }
//off //off
//player.off('ready',handleReady); //player.off('ready',handleReady);
@ -216,7 +216,7 @@ export default {
*/ */
play(){ play(){
// console.log(``); // console.log(``);
this.player.play(); this.player && this.player.play();
}, },
/** /**
@ -224,7 +224,7 @@ export default {
*/ */
pause(){ pause(){
// console.log(``); // console.log(``);
this.player.pause(); this.player && this.player.pause();
}, },
/** /**
@ -232,7 +232,7 @@ export default {
*/ */
replay(){ replay(){
// console.log(``); // console.log(``);
this.player.replay(); this.player && this.player.replay();
}, },
/** /**
@ -242,7 +242,7 @@ export default {
*/ */
seek(time){ seek(time){
// console.log(`time${time}`); // console.log(`time${time}`);
this.player.seek(time); this.player && this.player.seek(time);
}, },
/** /**
@ -250,8 +250,8 @@ export default {
* @return player * @return player
*/ */
getCurrentTime(){ getCurrentTime(){
// console.log(`${this.player.getCurrentTime()}`); // console.log(`${this.player && this.player.getCurrentTime()}`);
return this.player.getCurrentTime(); return this.player && this.player.getCurrentTime();
}, },
/** /**
@ -259,8 +259,8 @@ export default {
* @return player * @return player
*/ */
getDuration(){ getDuration(){
// console.log(`${this.player.getDuration()}`); // console.log(`${this.player && this.player.getDuration()}`);
return this.player.getDuration(); return this.player && this.player.getDuration();
}, },
/** /**
@ -268,8 +268,8 @@ export default {
* @return player * @return player
*/ */
getVolume(){ getVolume(){
// console.log(`${this.player.getVolume()}`); // console.log(`${this.player && this.player.getVolume()}`);
return this.player.getVolume(); return this.player && this.player.getVolume();
}, },
/** /**
@ -278,7 +278,7 @@ export default {
*/ */
setVolume(v){ setVolume(v){
// console.log(`vol${v}`); // console.log(`vol${v}`);
this.player.setVolume(v); this.player && this.player.setVolume(v);
}, },
/** /**
@ -288,7 +288,7 @@ export default {
*/ */
loadByUrl(url, time){ loadByUrl(url, time){
// console.log(`url${url}time${time}`); // console.log(`url${url}time${time}`);
this.player.loadByUrl(url, time); this.player && this.player.loadByUrl(url, time);
}, },
/** /**
@ -298,7 +298,7 @@ export default {
*/ */
replayByVidAndPlayAuth(vid, playauth){ replayByVidAndPlayAuth(vid, playauth){
// console.log(`replayByVidAndPlayAuth vid${vid}playauth${playauth}`); // console.log(`replayByVidAndPlayAuth vid${vid}playauth${playauth}`);
this.player.replayByVidAndPlayAuth(vid, playauth); this.player && this.player.replayByVidAndPlayAuth(vid, playauth);
}, },
/** /**
@ -309,7 +309,7 @@ export default {
*/ */
replayByVidAndAuthInfo(vid, accId, accSecret, stsToken, authInfo, domainRegion){ replayByVidAndAuthInfo(vid, accId, accSecret, stsToken, authInfo, domainRegion){
// console.log(`replayByVidAndAuthInfo vidaccIdaccSecretstsTokenauthInfodomainRegion`,vid, accId, accSecret, stsToken, authInfo, domainRegion); // console.log(`replayByVidAndAuthInfo vidaccIdaccSecretstsTokenauthInfodomainRegion`,vid, accId, accSecret, stsToken, authInfo, domainRegion);
this.player.replayByVidAndAuthInfo(vid, accId, accSecret, stsToken, authInfo, domainRegion); this.player && this.player.replayByVidAndAuthInfo(vid, accId, accSecret, stsToken, authInfo, domainRegion);
}, },
/** /**
@ -320,7 +320,7 @@ export default {
*/ */
setPlayerSize(w, h){ setPlayerSize(w, h){
// console.log(` :${w},:${h}`); // console.log(` :${w},:${h}`);
this.player.setPlayerSize(w, h); this.player && this.player.setPlayerSize(w, h);
}, },
/** /**
@ -332,7 +332,7 @@ export default {
*/ */
setSpeed(speed){ setSpeed(speed){
// console.log(`:${speed}`); // console.log(`:${speed}`);
this.player.setSpeed(speed); this.player && this.player.setSpeed(speed);
}, },
/** /**
@ -343,7 +343,7 @@ export default {
*/ */
setSanpshotProperties(width, height, rate){ setSanpshotProperties(width, height, rate){
// console.log(`:`,width, height, rate); // console.log(`:`,width, height, rate);
this.player.setSanpshotProperties(width, height, rate); this.player && this.player.setSanpshotProperties(width, height, rate);
}, },
/** /**
@ -351,7 +351,7 @@ export default {
*/ */
requestFullScreen(){ requestFullScreen(){
// console.log(`H5`); // console.log(`H5`);
this.player.fullscreenService && this.player.fullscreenService.requestFullScreen(); this.player && this.player.fullscreenService && this.player.fullscreenService.requestFullScreen();
}, },
/** /**
@ -359,15 +359,15 @@ export default {
*/ */
cancelFullScreen(){ cancelFullScreen(){
// console.log(`H5`); // console.log(`H5`);
this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen(); this.player && this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen();
}, },
/** /**
* 获取播放器全屏状态仅H5支持 * 获取播放器全屏状态仅H5支持
*/ */
getIsFullScreen(){ getIsFullScreen(){
// console.log(`H5`,this.player.fullscreenService && this.player.fullscreenService.getIsFullScreen()); // console.log(`H5`,this.player && this.player.fullscreenService && this.player && this.player.fullscreenService.getIsFullScreen());
return this.player.fullscreenService && this.player.fullscreenService.getIsFullScreen(); return this.player && this.player.fullscreenService && this.player.fullscreenService.getIsFullScreen();
}, },
/** /**
@ -375,8 +375,8 @@ export default {
* @returns init ready loading play pause playing waiting error ended * @returns init ready loading play pause playing waiting error ended
*/ */
getStatus(){ getStatus(){
// console.log(``,this.player.fullscreenService && this.player.fullscreenService.getStatus()); // console.log(``,this.player && this.player.fullscreenService && this.player && this.player.fullscreenService.getStatus());
return this.player.fullscreenService && this.player.fullscreenService.getStatus(); return this.player && this.player.fullscreenService && this.player.fullscreenService.getStatus();
}, },
/** /**
@ -387,7 +387,7 @@ export default {
*/ */
setLiveTimeRange(beginTime, endTime){ setLiveTimeRange(beginTime, endTime){
// console.log(`:${beginTime},:${endTime}使`); // console.log(`:${beginTime},:${endTime}使`);
this.player.liveShiftSerivce && this.player.liveShiftSerivce.setLiveTimeRange(beginTime, endTime); this.player && this.player.liveShiftSerivce && this.player.liveShiftSerivce.setLiveTimeRange(beginTime, endTime);
}, },
/** /**
@ -397,7 +397,7 @@ export default {
*/ */
setRotate(rotate){ setRotate(rotate){
// console.log(`:${rotate}`); // console.log(`:${rotate}`);
this.player.setRotate(rotate); this.player && this.player.setRotate(rotate);
}, },
/** /**
@ -405,8 +405,8 @@ export default {
* @return rotate 旋转角度 * @return rotate 旋转角度
*/ */
getRotate(){ getRotate(){
// console.log(`:${this.player.getRotate()}`); // console.log(`:${this.player && this.player.getRotate()}`);
return this.player.getRotate(); return this.player && this.player.getRotate();
}, },
/** /**
@ -416,7 +416,7 @@ export default {
*/ */
setImage(image){ setImage(image){
// console.log(`:${image}`); // console.log(`:${image}`);
this.player.setImage(image); this.player && this.player.setImage(image);
}, },
/** /**
@ -424,7 +424,7 @@ export default {
*/ */
dispose(){ dispose(){
// console.log(``); // console.log(``);
this.player.dispose(); this.player && this.player.dispose();
}, },
/** /**
@ -433,7 +433,7 @@ export default {
*/ */
setCover(cover){ setCover(cover){
// console.log(`:${cover}`); // console.log(`:${cover}`);
this.player.setCover(cover); this.player && this.player.setCover(cover);
}, },
/** /**
@ -442,7 +442,7 @@ export default {
*/ */
setProgressMarkers(markers){ setProgressMarkers(markers){
// console.log(`markers:${markers}`); // console.log(`markers:${markers}`);
this.player.setProgressMarkers(markers); this.player && this.player.setProgressMarkers(markers);
}, },
/** /**
@ -451,7 +451,7 @@ export default {
*/ */
setPreviewTime(time){ setPreviewTime(time){
// console.log(`:${time}`); // console.log(`:${time}`);
this.player.setPreviewTime(time); this.player && this.player.setPreviewTime(time);
}, },
/** /**
@ -459,8 +459,8 @@ export default {
* @return rotate 旋转角度 * @return rotate 旋转角度
*/ */
getPreviewTime(){ getPreviewTime(){
// console.log(`:${this.player.getPreviewTime()}`); // console.log(`:${this.player && this.player.getPreviewTime()}`);
return this.player.getPreviewTime(); return this.player && this.player.getPreviewTime();
}, },
/** /**
@ -468,7 +468,7 @@ export default {
*/ */
isPreview(){ isPreview(){
// console.log(``); // console.log(``);
this.player.isPreview(); this.player && this.player.isPreview();
}, },
/** /**
@ -476,8 +476,12 @@ export default {
* @param handle 回调方法 * @param handle 回调方法
*/ */
off(ev,handle){ off(ev,handle){
this.player.off(ev,handle); this.player && this.player.off(ev,handle);
} }
},
beforeDestroy(){ //,
console.log('beforeDestroy');
this.player && this.player.dispose();
} }
}; };
</script> </script>