增加生命生命周期销毁

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){
// console.log(this.config);
this.player = new Aliplayer(this.config);
this.player = Aliplayer(this.config);
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);
this.$emit(this.events[ev],e);
});
}
} else {
this.player.replay(); //
// console.log(`this.player.replay()`,'');
this.player && this.player.replay(); //
// console.log(`this.player && this.player.replay()`,'');
}
//off
//player.off('ready',handleReady);
@ -216,7 +216,7 @@ export default {
*/
play(){
// console.log(``);
this.player.play();
this.player && this.player.play();
},
/**
@ -224,7 +224,7 @@ export default {
*/
pause(){
// console.log(``);
this.player.pause();
this.player && this.player.pause();
},
/**
@ -232,7 +232,7 @@ export default {
*/
replay(){
// console.log(``);
this.player.replay();
this.player && this.player.replay();
},
/**
@ -242,7 +242,7 @@ export default {
*/
seek(time){
// console.log(`time${time}`);
this.player.seek(time);
this.player && this.player.seek(time);
},
/**
@ -250,8 +250,8 @@ export default {
* @return player
*/
getCurrentTime(){
// console.log(`${this.player.getCurrentTime()}`);
return this.player.getCurrentTime();
// console.log(`${this.player && this.player.getCurrentTime()}`);
return this.player && this.player.getCurrentTime();
},
/**
@ -259,8 +259,8 @@ export default {
* @return player
*/
getDuration(){
// console.log(`${this.player.getDuration()}`);
return this.player.getDuration();
// console.log(`${this.player && this.player.getDuration()}`);
return this.player && this.player.getDuration();
},
/**
@ -268,8 +268,8 @@ export default {
* @return player
*/
getVolume(){
// console.log(`${this.player.getVolume()}`);
return this.player.getVolume();
// console.log(`${this.player && this.player.getVolume()}`);
return this.player && this.player.getVolume();
},
/**
@ -278,7 +278,7 @@ export default {
*/
setVolume(v){
// console.log(`vol${v}`);
this.player.setVolume(v);
this.player && this.player.setVolume(v);
},
/**
@ -288,7 +288,7 @@ export default {
*/
loadByUrl(url, 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){
// 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){
// 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){
// console.log(` :${w},:${h}`);
this.player.setPlayerSize(w, h);
this.player && this.player.setPlayerSize(w, h);
},
/**
@ -332,7 +332,7 @@ export default {
*/
setSpeed(speed){
// console.log(`:${speed}`);
this.player.setSpeed(speed);
this.player && this.player.setSpeed(speed);
},
/**
@ -343,7 +343,7 @@ export default {
*/
setSanpshotProperties(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(){
// 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(){
// console.log(`H5`);
this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen();
this.player && this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen();
},
/**
* 获取播放器全屏状态仅H5支持
*/
getIsFullScreen(){
// console.log(`H5`,this.player.fullscreenService && this.player.fullscreenService.getIsFullScreen());
return this.player.fullscreenService && this.player.fullscreenService.getIsFullScreen();
// console.log(`H5`,this.player && this.player.fullscreenService && this.player && 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
*/
getStatus(){
// console.log(``,this.player.fullscreenService && this.player.fullscreenService.getStatus());
return this.player.fullscreenService && this.player.fullscreenService.getStatus();
// console.log(``,this.player && this.player.fullscreenService && this.player && this.player.fullscreenService.getStatus());
return this.player && this.player.fullscreenService && this.player.fullscreenService.getStatus();
},
/**
@ -387,7 +387,7 @@ export default {
*/
setLiveTimeRange(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){
// console.log(`:${rotate}`);
this.player.setRotate(rotate);
this.player && this.player.setRotate(rotate);
},
/**
@ -405,8 +405,8 @@ export default {
* @return rotate 旋转角度
*/
getRotate(){
// console.log(`:${this.player.getRotate()}`);
return this.player.getRotate();
// console.log(`:${this.player && this.player.getRotate()}`);
return this.player && this.player.getRotate();
},
/**
@ -416,7 +416,7 @@ export default {
*/
setImage(image){
// console.log(`:${image}`);
this.player.setImage(image);
this.player && this.player.setImage(image);
},
/**
@ -424,7 +424,7 @@ export default {
*/
dispose(){
// console.log(``);
this.player.dispose();
this.player && this.player.dispose();
},
/**
@ -433,7 +433,7 @@ export default {
*/
setCover(cover){
// console.log(`:${cover}`);
this.player.setCover(cover);
this.player && this.player.setCover(cover);
},
/**
@ -442,7 +442,7 @@ export default {
*/
setProgressMarkers(markers){
// console.log(`markers:${markers}`);
this.player.setProgressMarkers(markers);
this.player && this.player.setProgressMarkers(markers);
},
/**
@ -451,7 +451,7 @@ export default {
*/
setPreviewTime(time){
// console.log(`:${time}`);
this.player.setPreviewTime(time);
this.player && this.player.setPreviewTime(time);
},
/**
@ -459,8 +459,8 @@ export default {
* @return rotate 旋转角度
*/
getPreviewTime(){
// console.log(`:${this.player.getPreviewTime()}`);
return this.player.getPreviewTime();
// console.log(`:${this.player && this.player.getPreviewTime()}`);
return this.player && this.player.getPreviewTime();
},
/**
@ -468,7 +468,7 @@ export default {
*/
isPreview(){
// console.log(``);
this.player.isPreview();
this.player && this.player.isPreview();
},
/**
@ -476,8 +476,12 @@ export default {
* @param 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>