diff --git a/lib/vue-aliplayer-v2.common.js b/lib/vue-aliplayer-v2.common.js index ba588fa..19b520e 100644 --- a/lib/vue-aliplayer-v2.common.js +++ b/lib/vue-aliplayer-v2.common.js @@ -127,12 +127,12 @@ if (typeof window !== 'undefined') { // EXTERNAL MODULE: ./node_modules/_core-js@2.6.10@core-js/modules/es6.function.name.js var es6_function_name = __webpack_require__("7cfd"); -// CONCATENATED MODULE: ./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"05d0d90a-vue-loader-template"}!./node_modules/_vue-loader@15.7.2@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--0-0!./node_modules/_vue-loader@15.7.2@vue-loader/lib??vue-loader-options!./packages/AliplayerV2/src/main.vue?vue&type=template&id=2be8a9a5& +// CONCATENATED MODULE: ./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"05d0d90a-vue-loader-template"}!./node_modules/_vue-loader@15.7.2@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--0-0!./node_modules/_vue-loader@15.7.2@vue-loader/lib??vue-loader-options!./packages/AliplayerV2/src/main.vue?vue&type=template&id=f3242f72& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{"id":_vm.id}})} var staticRenderFns = [] -// CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=template&id=2be8a9a5& +// CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=template&id=f3242f72& // CONCATENATED MODULE: ./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--12-0!./node_modules/_thread-loader@2.1.3@thread-loader/dist/cjs.js!./node_modules/_babel-loader@8.0.6@babel-loader/lib!./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--0-0!./node_modules/_vue-loader@15.7.2@vue-loader/lib??vue-loader-options!./packages/AliplayerV2/src/main.vue?vue&type=script&lang=js& // @@ -342,10 +342,10 @@ var staticRenderFns = [] if (!this.player) { // console.log(this.config); - this.player = new Aliplayer(this.config); + this.player = Aliplayer(this.config); var _loop = function _loop(ev) { - _this4.player.on(_this4.events[ev], function (e) { + _this4.player && _this4.player.on(_this4.events[ev], function (e) { // console.log(`object ${this.events[ev]}`,e); _this4.$emit(_this4.events[ev], e); }); @@ -355,8 +355,8 @@ var staticRenderFns = [] _loop(ev); } } 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); @@ -375,7 +375,7 @@ var staticRenderFns = [] */ play: function play() { // console.log(`播放视频。`); - this.player.play(); + this.player && this.player.play(); }, /** @@ -383,7 +383,7 @@ var staticRenderFns = [] */ pause: function pause() { // console.log(`暂停视频`); - this.player.pause(); + this.player && this.player.pause(); }, /** @@ -391,7 +391,7 @@ var staticRenderFns = [] */ replay: function replay() { // console.log(`重播视频`); - this.player.replay(); + this.player && this.player.replay(); }, /** @@ -401,7 +401,7 @@ var staticRenderFns = [] */ seek: function seek(time) { // console.log(`跳转到某个时刻进行播放,time为${time}秒。`); - this.player.seek(time); + this.player && this.player.seek(time); }, /** @@ -409,8 +409,8 @@ var staticRenderFns = [] * @return player */ getCurrentTime: function getCurrentTime() { - // console.log(`获取当前的播放时刻,返回的单位为${this.player.getCurrentTime()}秒。`); - return this.player.getCurrentTime(); + // console.log(`获取当前的播放时刻,返回的单位为${this.player && this.player.getCurrentTime()}秒。`); + return this.player && this.player.getCurrentTime(); }, /** @@ -418,8 +418,8 @@ var staticRenderFns = [] * @return player */ getDuration: function getDuration() { - // console.log(`获取视频总时长,返回的单位为${this.player.getDuration()}秒。`); - return this.player.getDuration(); + // console.log(`获取视频总时长,返回的单位为${this.player && this.player.getDuration()}秒。`); + return this.player && this.player.getDuration(); }, /** @@ -427,8 +427,8 @@ var staticRenderFns = [] * @return player */ getVolume: function getVolume() { - // console.log(`获取当前的音量${this.player.getVolume()}。`); - return this.player.getVolume(); + // console.log(`获取当前的音量${this.player && this.player.getVolume()}。`); + return this.player && this.player.getVolume(); }, /** @@ -437,7 +437,7 @@ var staticRenderFns = [] */ setVolume: function setVolume(v) { // console.log(`设置音量,vol为${v}。`); - this.player.setVolume(v); + this.player && this.player.setVolume(v); }, /** @@ -447,7 +447,7 @@ var staticRenderFns = [] */ loadByUrl: function loadByUrl(url, time) { // console.log(`直接播放视频url${url},time为${time}。`); - this.player.loadByUrl(url, time); + this.player && this.player.loadByUrl(url, time); }, /** @@ -457,7 +457,7 @@ var staticRenderFns = [] */ replayByVidAndPlayAuth: function replayByVidAndPlayAuth(vid, playauth) { // console.log(`replayByVidAndPlayAuth vid${vid},playauth为${playauth}。`); - this.player.replayByVidAndPlayAuth(vid, playauth); + this.player && this.player.replayByVidAndPlayAuth(vid, playauth); }, /** @@ -468,7 +468,7 @@ var staticRenderFns = [] */ replayByVidAndAuthInfo: function replayByVidAndAuthInfo(vid, accId, accSecret, stsToken, authInfo, domainRegion) { // console.log(`replayByVidAndAuthInfo 参数顺序为:vid、accId、accSecret、stsToken、authInfo、domainRegion`,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); }, /** @@ -479,7 +479,7 @@ var staticRenderFns = [] */ setPlayerSize: function setPlayerSize(w, h) { // console.log(`设置播放器大小 宽度:${w},高度:${h}`); - this.player.setPlayerSize(w, h); + this.player && this.player.setPlayerSize(w, h); }, /** @@ -491,7 +491,7 @@ var staticRenderFns = [] */ setSpeed: function setSpeed(speed) { // console.log(`手动设置播放的倍速:${speed}`); - this.player.setSpeed(speed); + this.player && this.player.setSpeed(speed); }, /** @@ -502,7 +502,7 @@ var staticRenderFns = [] */ setSanpshotProperties: function setSanpshotProperties(width, height, rate) { // console.log(`设置截图参数:`,width, height, rate); - this.player.setSanpshotProperties(width, height, rate); + this.player && this.player.setSanpshotProperties(width, height, rate); }, /** @@ -510,7 +510,7 @@ var staticRenderFns = [] */ requestFullScreen: function requestFullScreen() { // console.log(`播放器全屏,仅H5支持`); - this.player.fullscreenService && this.player.fullscreenService.requestFullScreen(); + this.player && this.player.fullscreenService && this.player.fullscreenService.requestFullScreen(); }, /** @@ -518,15 +518,15 @@ var staticRenderFns = [] */ cancelFullScreen: function cancelFullScreen() { // console.log(`播放器全屏,仅H5支持`); - this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen(); + this.player && this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen(); }, /** * 获取播放器全屏状态,仅H5支持。 */ getIsFullScreen: function 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(); }, /** @@ -534,8 +534,8 @@ var staticRenderFns = [] * @returns init ready loading play pause playing waiting error ended */ getStatus: function 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(); }, /** @@ -546,7 +546,7 @@ var staticRenderFns = [] */ setLiveTimeRange: function 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); }, /** @@ -556,7 +556,7 @@ var staticRenderFns = [] */ setRotate: function setRotate(rotate) { // console.log(`参数为旋转角度:${rotate}。`); - this.player.setRotate(rotate); + this.player && this.player.setRotate(rotate); }, /** @@ -564,8 +564,8 @@ var staticRenderFns = [] * @return rotate 旋转角度 */ getRotate: function getRotate() { - // console.log(`获取旋转角度:${this.player.getRotate()}`); - return this.player.getRotate(); + // console.log(`获取旋转角度:${this.player && this.player.getRotate()}`); + return this.player && this.player.getRotate(); }, /** @@ -575,7 +575,7 @@ var staticRenderFns = [] */ setImage: function setImage(image) { // console.log(`设置镜像:${image}。`); - this.player.setImage(image); + this.player && this.player.setImage(image); }, /** @@ -583,7 +583,7 @@ var staticRenderFns = [] */ dispose: function dispose() { // console.log(`播放器销毁。`); - this.player.dispose(); + this.player && this.player.dispose(); }, /** @@ -592,7 +592,7 @@ var staticRenderFns = [] */ setCover: function setCover(cover) { // console.log(`设置封面:${cover}`); - this.player.setCover(cover); + this.player && this.player.setCover(cover); }, /** @@ -601,7 +601,7 @@ var staticRenderFns = [] */ setProgressMarkers: function setProgressMarkers(markers) { // console.log(`markers打点数据集合:${markers}`); - this.player.setProgressMarkers(markers); + this.player && this.player.setProgressMarkers(markers); }, /** @@ -610,7 +610,7 @@ var staticRenderFns = [] */ setPreviewTime: function setPreviewTime(time) { // console.log(`设置试看时间,单位为:${time}秒`); - this.player.setPreviewTime(time); + this.player && this.player.setPreviewTime(time); }, /** @@ -618,8 +618,8 @@ var staticRenderFns = [] * @return rotate 旋转角度 */ getPreviewTime: function getPreviewTime() { - // console.log(`获取试看时间:${this.player.getPreviewTime()}`); - return this.player.getPreviewTime(); + // console.log(`获取试看时间:${this.player && this.player.getPreviewTime()}`); + return this.player && this.player.getPreviewTime(); }, /** @@ -627,7 +627,7 @@ var staticRenderFns = [] */ isPreview: function isPreview() { // console.log(`是否试看`); - this.player.isPreview(); + this.player && this.player.isPreview(); }, /** @@ -635,8 +635,13 @@ var staticRenderFns = [] * @param handle 回调方法 */ off: function off(ev, handle) { - this.player.off(ev, handle); + this.player && this.player.off(ev, handle); } + }, + beforeDestroy: function beforeDestroy() { + //防止重复创建,需要销毁原来的播放器 + console.log('beforeDestroy'); + this.player && this.player.dispose(); } }); // CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=script&lang=js& diff --git a/lib/vue-aliplayer-v2.umd.js b/lib/vue-aliplayer-v2.umd.js index f40e7c2..26f1ed7 100644 --- a/lib/vue-aliplayer-v2.umd.js +++ b/lib/vue-aliplayer-v2.umd.js @@ -136,12 +136,12 @@ if (typeof window !== 'undefined') { // EXTERNAL MODULE: ./node_modules/_core-js@2.6.10@core-js/modules/es6.function.name.js var es6_function_name = __webpack_require__("7cfd"); -// CONCATENATED MODULE: ./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"05d0d90a-vue-loader-template"}!./node_modules/_vue-loader@15.7.2@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--0-0!./node_modules/_vue-loader@15.7.2@vue-loader/lib??vue-loader-options!./packages/AliplayerV2/src/main.vue?vue&type=template&id=2be8a9a5& +// CONCATENATED MODULE: ./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"05d0d90a-vue-loader-template"}!./node_modules/_vue-loader@15.7.2@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--0-0!./node_modules/_vue-loader@15.7.2@vue-loader/lib??vue-loader-options!./packages/AliplayerV2/src/main.vue?vue&type=template&id=f3242f72& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{"id":_vm.id}})} var staticRenderFns = [] -// CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=template&id=2be8a9a5& +// CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=template&id=f3242f72& // CONCATENATED MODULE: ./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--12-0!./node_modules/_thread-loader@2.1.3@thread-loader/dist/cjs.js!./node_modules/_babel-loader@8.0.6@babel-loader/lib!./node_modules/_cache-loader@2.0.1@cache-loader/dist/cjs.js??ref--0-0!./node_modules/_vue-loader@15.7.2@vue-loader/lib??vue-loader-options!./packages/AliplayerV2/src/main.vue?vue&type=script&lang=js& // @@ -351,10 +351,10 @@ var staticRenderFns = [] if (!this.player) { // console.log(this.config); - this.player = new Aliplayer(this.config); + this.player = Aliplayer(this.config); var _loop = function _loop(ev) { - _this4.player.on(_this4.events[ev], function (e) { + _this4.player && _this4.player.on(_this4.events[ev], function (e) { // console.log(`object ${this.events[ev]}`,e); _this4.$emit(_this4.events[ev], e); }); @@ -364,8 +364,8 @@ var staticRenderFns = [] _loop(ev); } } 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); @@ -384,7 +384,7 @@ var staticRenderFns = [] */ play: function play() { // console.log(`播放视频。`); - this.player.play(); + this.player && this.player.play(); }, /** @@ -392,7 +392,7 @@ var staticRenderFns = [] */ pause: function pause() { // console.log(`暂停视频`); - this.player.pause(); + this.player && this.player.pause(); }, /** @@ -400,7 +400,7 @@ var staticRenderFns = [] */ replay: function replay() { // console.log(`重播视频`); - this.player.replay(); + this.player && this.player.replay(); }, /** @@ -410,7 +410,7 @@ var staticRenderFns = [] */ seek: function seek(time) { // console.log(`跳转到某个时刻进行播放,time为${time}秒。`); - this.player.seek(time); + this.player && this.player.seek(time); }, /** @@ -418,8 +418,8 @@ var staticRenderFns = [] * @return player */ getCurrentTime: function getCurrentTime() { - // console.log(`获取当前的播放时刻,返回的单位为${this.player.getCurrentTime()}秒。`); - return this.player.getCurrentTime(); + // console.log(`获取当前的播放时刻,返回的单位为${this.player && this.player.getCurrentTime()}秒。`); + return this.player && this.player.getCurrentTime(); }, /** @@ -427,8 +427,8 @@ var staticRenderFns = [] * @return player */ getDuration: function getDuration() { - // console.log(`获取视频总时长,返回的单位为${this.player.getDuration()}秒。`); - return this.player.getDuration(); + // console.log(`获取视频总时长,返回的单位为${this.player && this.player.getDuration()}秒。`); + return this.player && this.player.getDuration(); }, /** @@ -436,8 +436,8 @@ var staticRenderFns = [] * @return player */ getVolume: function getVolume() { - // console.log(`获取当前的音量${this.player.getVolume()}。`); - return this.player.getVolume(); + // console.log(`获取当前的音量${this.player && this.player.getVolume()}。`); + return this.player && this.player.getVolume(); }, /** @@ -446,7 +446,7 @@ var staticRenderFns = [] */ setVolume: function setVolume(v) { // console.log(`设置音量,vol为${v}。`); - this.player.setVolume(v); + this.player && this.player.setVolume(v); }, /** @@ -456,7 +456,7 @@ var staticRenderFns = [] */ loadByUrl: function loadByUrl(url, time) { // console.log(`直接播放视频url${url},time为${time}。`); - this.player.loadByUrl(url, time); + this.player && this.player.loadByUrl(url, time); }, /** @@ -466,7 +466,7 @@ var staticRenderFns = [] */ replayByVidAndPlayAuth: function replayByVidAndPlayAuth(vid, playauth) { // console.log(`replayByVidAndPlayAuth vid${vid},playauth为${playauth}。`); - this.player.replayByVidAndPlayAuth(vid, playauth); + this.player && this.player.replayByVidAndPlayAuth(vid, playauth); }, /** @@ -477,7 +477,7 @@ var staticRenderFns = [] */ replayByVidAndAuthInfo: function replayByVidAndAuthInfo(vid, accId, accSecret, stsToken, authInfo, domainRegion) { // console.log(`replayByVidAndAuthInfo 参数顺序为:vid、accId、accSecret、stsToken、authInfo、domainRegion`,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); }, /** @@ -488,7 +488,7 @@ var staticRenderFns = [] */ setPlayerSize: function setPlayerSize(w, h) { // console.log(`设置播放器大小 宽度:${w},高度:${h}`); - this.player.setPlayerSize(w, h); + this.player && this.player.setPlayerSize(w, h); }, /** @@ -500,7 +500,7 @@ var staticRenderFns = [] */ setSpeed: function setSpeed(speed) { // console.log(`手动设置播放的倍速:${speed}`); - this.player.setSpeed(speed); + this.player && this.player.setSpeed(speed); }, /** @@ -511,7 +511,7 @@ var staticRenderFns = [] */ setSanpshotProperties: function setSanpshotProperties(width, height, rate) { // console.log(`设置截图参数:`,width, height, rate); - this.player.setSanpshotProperties(width, height, rate); + this.player && this.player.setSanpshotProperties(width, height, rate); }, /** @@ -519,7 +519,7 @@ var staticRenderFns = [] */ requestFullScreen: function requestFullScreen() { // console.log(`播放器全屏,仅H5支持`); - this.player.fullscreenService && this.player.fullscreenService.requestFullScreen(); + this.player && this.player.fullscreenService && this.player.fullscreenService.requestFullScreen(); }, /** @@ -527,15 +527,15 @@ var staticRenderFns = [] */ cancelFullScreen: function cancelFullScreen() { // console.log(`播放器全屏,仅H5支持`); - this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen(); + this.player && this.player.fullscreenService && this.player.fullscreenService.cancelFullScreen(); }, /** * 获取播放器全屏状态,仅H5支持。 */ getIsFullScreen: function 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(); }, /** @@ -543,8 +543,8 @@ var staticRenderFns = [] * @returns init ready loading play pause playing waiting error ended */ getStatus: function 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(); }, /** @@ -555,7 +555,7 @@ var staticRenderFns = [] */ setLiveTimeRange: function 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); }, /** @@ -565,7 +565,7 @@ var staticRenderFns = [] */ setRotate: function setRotate(rotate) { // console.log(`参数为旋转角度:${rotate}。`); - this.player.setRotate(rotate); + this.player && this.player.setRotate(rotate); }, /** @@ -573,8 +573,8 @@ var staticRenderFns = [] * @return rotate 旋转角度 */ getRotate: function getRotate() { - // console.log(`获取旋转角度:${this.player.getRotate()}`); - return this.player.getRotate(); + // console.log(`获取旋转角度:${this.player && this.player.getRotate()}`); + return this.player && this.player.getRotate(); }, /** @@ -584,7 +584,7 @@ var staticRenderFns = [] */ setImage: function setImage(image) { // console.log(`设置镜像:${image}。`); - this.player.setImage(image); + this.player && this.player.setImage(image); }, /** @@ -592,7 +592,7 @@ var staticRenderFns = [] */ dispose: function dispose() { // console.log(`播放器销毁。`); - this.player.dispose(); + this.player && this.player.dispose(); }, /** @@ -601,7 +601,7 @@ var staticRenderFns = [] */ setCover: function setCover(cover) { // console.log(`设置封面:${cover}`); - this.player.setCover(cover); + this.player && this.player.setCover(cover); }, /** @@ -610,7 +610,7 @@ var staticRenderFns = [] */ setProgressMarkers: function setProgressMarkers(markers) { // console.log(`markers打点数据集合:${markers}`); - this.player.setProgressMarkers(markers); + this.player && this.player.setProgressMarkers(markers); }, /** @@ -619,7 +619,7 @@ var staticRenderFns = [] */ setPreviewTime: function setPreviewTime(time) { // console.log(`设置试看时间,单位为:${time}秒`); - this.player.setPreviewTime(time); + this.player && this.player.setPreviewTime(time); }, /** @@ -627,8 +627,8 @@ var staticRenderFns = [] * @return rotate 旋转角度 */ getPreviewTime: function getPreviewTime() { - // console.log(`获取试看时间:${this.player.getPreviewTime()}`); - return this.player.getPreviewTime(); + // console.log(`获取试看时间:${this.player && this.player.getPreviewTime()}`); + return this.player && this.player.getPreviewTime(); }, /** @@ -636,7 +636,7 @@ var staticRenderFns = [] */ isPreview: function isPreview() { // console.log(`是否试看`); - this.player.isPreview(); + this.player && this.player.isPreview(); }, /** @@ -644,8 +644,13 @@ var staticRenderFns = [] * @param handle 回调方法 */ off: function off(ev, handle) { - this.player.off(ev, handle); + this.player && this.player.off(ev, handle); } + }, + beforeDestroy: function beforeDestroy() { + //防止重复创建,需要销毁原来的播放器 + console.log('beforeDestroy'); + this.player && this.player.dispose(); } }); // CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=script&lang=js& diff --git a/lib/vue-aliplayer-v2.umd.min.js b/lib/vue-aliplayer-v2.umd.min.js index f1296de..6aecd8b 100644 --- a/lib/vue-aliplayer-v2.umd.min.js +++ b/lib/vue-aliplayer-v2.umd.min.js @@ -1,2 +1,2 @@ -(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["vue-aliplayer-v2"]=t():e["vue-aliplayer-v2"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="112a")}({"0cc1":function(e,t){e.exports=function(e){try{return!!e()}catch(t){return!0}}},"112a":function(e,t,n){"use strict";var r;(n.r(t),"undefined"!==typeof window)&&(n("e67d"),(r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=r[1]));n("7cfd");var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:e.id}})},o=[],a={name:"VueAliplayerV2",props:{options:{required:!1,type:[Object],default:function(){return null}},id:{required:!1,type:[String],default:"player-".concat(Date.parse(new Date))},cssLink:{required:!1,type:[String],default:"https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css"},scriptSrc:{required:!1,type:[String],default:"https://g.alicdn.com/de/prismplayer/2.8.2/aliplayer-min.js"}},data:function(){return{player:null,config:{id:null,width:"100%",autoplay:!0},events:["ready","play","pause","canplay","playing","ended","liveStreamStop","onM3u8Retry","hideBar","showBar","waiting","timeupdate","snapshoted","requestFullScreen","cancelFullScreen","error","startSeek","completeSeek"]}},mounted:function(){var e=this;this.$nextTick((function(){e.init()}))},updated:function(){var e=this;this.$nextTick((function(){e.init()}))},methods:{init:function(){var e=this,t="aliplayer-min-css",n="aliplayer-min-js",r=document.getElementsByTagName("head"),i=document.getElementsByTagName("html"),o=document.getElementById(n),a=document.getElementById(t);if(!a){var u=document.createElement("link");u.type="text/css",u.rel="stylesheet",u.href=this.cssLink,u.id=t,r[0].appendChild(u)}o||(o=document.createElement("script"),o.type="text/javascript",o.id=n,o.src=this.scriptSrc,i[0].appendChild(o)),o&&a?this.initPlayer():o.addEventListener("load",(function(){e.initPlayer()}))},initPlayer:function(){var e=this;if("undefined"!=typeof window.Aliplayer){var t=this.options;if(t)for(var n in t)this.config[n]=t[n];if(this.config.id=this.id,this.player)this.player.replay();else{this.player=new Aliplayer(this.config);var r=function(t){e.player.on(e.events[t],(function(n){e.$emit(e.events[t],n)}))};for(var i in this.events)r(i)}}},getPlayer:function(){return this.player},play:function(){this.player.play()},pause:function(){this.player.pause()},replay:function(){this.player.replay()},seek:function(e){this.player.seek(e)},getCurrentTime:function(){return this.player.getCurrentTime()},getDuration:function(){return this.player.getDuration()},getVolume:function(){return this.player.getVolume()},setVolume:function(e){this.player.setVolume(e)},loadByUrl:function(e,t){this.player.loadByUrl(e,t)},replayByVidAndPlayAuth:function(e,t){this.player.replayByVidAndPlayAuth(e,t)},replayByVidAndAuthInfo:function(e,t,n,r,i,o){this.player.replayByVidAndAuthInfo(e,t,n,r,i,o)},setPlayerSize:function(e,t){this.player.setPlayerSize(e,t)},setSpeed:function(e){this.player.setSpeed(e)},setSanpshotProperties:function(e,t,n){this.player.setSanpshotProperties(e,t,n)},requestFullScreen:function(){this.player.fullscreenService&&this.player.fullscreenService.requestFullScreen()},cancelFullScreen:function(){this.player.fullscreenService&&this.player.fullscreenService.cancelFullScreen()},getIsFullScreen:function(){return this.player.fullscreenService&&this.player.fullscreenService.getIsFullScreen()},getStatus:function(){return this.player.fullscreenService&&this.player.fullscreenService.getStatus()},setLiveTimeRange:function(e,t){this.player.liveShiftSerivce&&this.player.liveShiftSerivce.setLiveTimeRange(e,t)},setRotate:function(e){this.player.setRotate(e)},getRotate:function(){return this.player.getRotate()},setImage:function(e){this.player.setImage(e)},dispose:function(){this.player.dispose()},setCover:function(e){this.player.setCover(e)},setProgressMarkers:function(e){this.player.setProgressMarkers(e)},setPreviewTime:function(e){this.player.setPreviewTime(e)},getPreviewTime:function(){return this.player.getPreviewTime()},isPreview:function(){this.player.isPreview()},off:function(e,t){this.player.off(e,t)}}},u=a;function c(e,t,n,r,i,o,a,u){var c,l="function"===typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),r&&(l.functional=!0),o&&(l._scopeId="data-v-"+o),a?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(a)},l._ssrRegister=c):i&&(c=u?function(){i.call(this,this.$root.$options.shadowRoot)}:i),c)if(l.functional){l._injectStyles=c;var s=l.render;l.render=function(e,t){return c.call(t),s(e,t)}}else{var f=l.beforeCreate;l.beforeCreate=f?[].concat(f,c):[c]}return{exports:e,options:l}}var l=c(u,i,o,!1,null,null,null),s=l.exports;s.install=function(e){e.component(s.name,s)};var f=s,p=[f],d=function e(t){if(e.installed)return!1;e.installed=!0,p.map((function(e){return t.component(e.name,e)}))};"undefined"!==typeof window&&window.Vue&&d(window.Vue);var y={install:d,VueAliplayerV2:f};t["default"]=y},"25ae":function(e,t,n){e.exports=!n("f9a5")&&!n("0cc1")((function(){return 7!=Object.defineProperty(n("6618")("div"),"a",{get:function(){return 7}}).a}))},"2ab1":function(e,t,n){var r=n("da0b");e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},"3f8b":function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},6618:function(e,t,n){var r=n("da0b"),i=n("3f8b").document,o=r(i)&&r(i.createElement);e.exports=function(e){return o?i.createElement(e):{}}},"7cfd":function(e,t,n){var r=n("d3d8").f,i=Function.prototype,o=/^\s*function ([^ (]*)/,a="name";a in i||n("f9a5")&&r(i,a,{configurable:!0,get:function(){try{return(""+this).match(o)[1]}catch(e){return""}}})},"8cac":function(e,t,n){var r=n("da0b");e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},d3d8:function(e,t,n){var r=n("8cac"),i=n("25ae"),o=n("2ab1"),a=Object.defineProperty;t.f=n("f9a5")?Object.defineProperty:function(e,t,n){if(r(e),t=o(t,!0),r(n),i)try{return a(e,t,n)}catch(u){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},da0b:function(e,t){e.exports=function(e){return"object"===typeof e?null!==e:"function"===typeof e}},e67d:function(e,t){(function(e){var t="currentScript",n=e.getElementsByTagName("script");t in e||Object.defineProperty(e,t,{get:function(){try{throw new Error}catch(r){var e,t=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(r.stack)||[!1])[1];for(e in n)if(n[e].src==t||"interactive"==n[e].readyState)return n[e];return null}}})})(document)},f9a5:function(e,t,n){e.exports=!n("0cc1")((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))}})})); +(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["vue-aliplayer-v2"]=t():e["vue-aliplayer-v2"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="112a")}({"0cc1":function(e,t){e.exports=function(e){try{return!!e()}catch(t){return!0}}},"112a":function(e,t,n){"use strict";var r;(n.r(t),"undefined"!==typeof window)&&(n("e67d"),(r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=r[1]));n("7cfd");var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:e.id}})},a=[],o={name:"VueAliplayerV2",props:{options:{required:!1,type:[Object],default:function(){return null}},id:{required:!1,type:[String],default:"player-".concat(Date.parse(new Date))},cssLink:{required:!1,type:[String],default:"https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css"},scriptSrc:{required:!1,type:[String],default:"https://g.alicdn.com/de/prismplayer/2.8.2/aliplayer-min.js"}},data:function(){return{player:null,config:{id:null,width:"100%",autoplay:!0},events:["ready","play","pause","canplay","playing","ended","liveStreamStop","onM3u8Retry","hideBar","showBar","waiting","timeupdate","snapshoted","requestFullScreen","cancelFullScreen","error","startSeek","completeSeek"]}},mounted:function(){var e=this;this.$nextTick((function(){e.init()}))},updated:function(){var e=this;this.$nextTick((function(){e.init()}))},methods:{init:function(){var e=this,t="aliplayer-min-css",n="aliplayer-min-js",r=document.getElementsByTagName("head"),i=document.getElementsByTagName("html"),a=document.getElementById(n),o=document.getElementById(t);if(!o){var s=document.createElement("link");s.type="text/css",s.rel="stylesheet",s.href=this.cssLink,s.id=t,r[0].appendChild(s)}a||(a=document.createElement("script"),a.type="text/javascript",a.id=n,a.src=this.scriptSrc,i[0].appendChild(a)),a&&o?this.initPlayer():a.addEventListener("load",(function(){e.initPlayer()}))},initPlayer:function(){var e=this;if("undefined"!=typeof window.Aliplayer){var t=this.options;if(t)for(var n in t)this.config[n]=t[n];if(this.config.id=this.id,this.player)this.player&&this.player.replay();else{this.player=Aliplayer(this.config);var r=function(t){e.player&&e.player.on(e.events[t],(function(n){e.$emit(e.events[t],n)}))};for(var i in this.events)r(i)}}},getPlayer:function(){return this.player},play:function(){this.player&&this.player.play()},pause:function(){this.player&&this.player.pause()},replay:function(){this.player&&this.player.replay()},seek:function(e){this.player&&this.player.seek(e)},getCurrentTime:function(){return this.player&&this.player.getCurrentTime()},getDuration:function(){return this.player&&this.player.getDuration()},getVolume:function(){return this.player&&this.player.getVolume()},setVolume:function(e){this.player&&this.player.setVolume(e)},loadByUrl:function(e,t){this.player&&this.player.loadByUrl(e,t)},replayByVidAndPlayAuth:function(e,t){this.player&&this.player.replayByVidAndPlayAuth(e,t)},replayByVidAndAuthInfo:function(e,t,n,r,i,a){this.player&&this.player.replayByVidAndAuthInfo(e,t,n,r,i,a)},setPlayerSize:function(e,t){this.player&&this.player.setPlayerSize(e,t)},setSpeed:function(e){this.player&&this.player.setSpeed(e)},setSanpshotProperties:function(e,t,n){this.player&&this.player.setSanpshotProperties(e,t,n)},requestFullScreen:function(){this.player&&this.player.fullscreenService&&this.player.fullscreenService.requestFullScreen()},cancelFullScreen:function(){this.player&&this.player.fullscreenService&&this.player.fullscreenService.cancelFullScreen()},getIsFullScreen:function(){return this.player&&this.player.fullscreenService&&this.player.fullscreenService.getIsFullScreen()},getStatus:function(){return this.player&&this.player.fullscreenService&&this.player.fullscreenService.getStatus()},setLiveTimeRange:function(e,t){this.player&&this.player.liveShiftSerivce&&this.player.liveShiftSerivce.setLiveTimeRange(e,t)},setRotate:function(e){this.player&&this.player.setRotate(e)},getRotate:function(){return this.player&&this.player.getRotate()},setImage:function(e){this.player&&this.player.setImage(e)},dispose:function(){this.player&&this.player.dispose()},setCover:function(e){this.player&&this.player.setCover(e)},setProgressMarkers:function(e){this.player&&this.player.setProgressMarkers(e)},setPreviewTime:function(e){this.player&&this.player.setPreviewTime(e)},getPreviewTime:function(){return this.player&&this.player.getPreviewTime()},isPreview:function(){this.player&&this.player.isPreview()},off:function(e,t){this.player&&this.player.off(e,t)}},beforeDestroy:function(){console.log("beforeDestroy"),this.player&&this.player.dispose()}},s=o;function l(e,t,n,r,i,a,o,s){var l,u="function"===typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),r&&(u.functional=!0),a&&(u._scopeId="data-v-"+a),o?(l=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=l):i&&(l=s?function(){i.call(this,this.$root.$options.shadowRoot)}:i),l)if(u.functional){u._injectStyles=l;var c=u.render;u.render=function(e,t){return l.call(t),c(e,t)}}else{var p=u.beforeCreate;u.beforeCreate=p?[].concat(p,l):[l]}return{exports:e,options:u}}var u=l(s,i,a,!1,null,null,null),c=u.exports;c.install=function(e){e.component(c.name,c)};var p=c,f=[p],y=function e(t){if(e.installed)return!1;e.installed=!0,f.map((function(e){return t.component(e.name,e)}))};"undefined"!==typeof window&&window.Vue&&y(window.Vue);var d={install:y,VueAliplayerV2:p};t["default"]=d},"25ae":function(e,t,n){e.exports=!n("f9a5")&&!n("0cc1")((function(){return 7!=Object.defineProperty(n("6618")("div"),"a",{get:function(){return 7}}).a}))},"2ab1":function(e,t,n){var r=n("da0b");e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},"3f8b":function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},6618:function(e,t,n){var r=n("da0b"),i=n("3f8b").document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},"7cfd":function(e,t,n){var r=n("d3d8").f,i=Function.prototype,a=/^\s*function ([^ (]*)/,o="name";o in i||n("f9a5")&&r(i,o,{configurable:!0,get:function(){try{return(""+this).match(a)[1]}catch(e){return""}}})},"8cac":function(e,t,n){var r=n("da0b");e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},d3d8:function(e,t,n){var r=n("8cac"),i=n("25ae"),a=n("2ab1"),o=Object.defineProperty;t.f=n("f9a5")?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch(s){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},da0b:function(e,t){e.exports=function(e){return"object"===typeof e?null!==e:"function"===typeof e}},e67d:function(e,t){(function(e){var t="currentScript",n=e.getElementsByTagName("script");t in e||Object.defineProperty(e,t,{get:function(){try{throw new Error}catch(r){var e,t=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(r.stack)||[!1])[1];for(e in n)if(n[e].src==t||"interactive"==n[e].readyState)return n[e];return null}}})})(document)},f9a5:function(e,t,n){e.exports=!n("0cc1")((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))}})})); //# sourceMappingURL=vue-aliplayer-v2.umd.min.js.map \ No newline at end of file diff --git a/packages/AliplayerV2/src/main.vue b/packages/AliplayerV2/src/main.vue index cf8c97d..6dea2ea 100644 --- a/packages/AliplayerV2/src/main.vue +++ b/packages/AliplayerV2/src/main.vue @@ -480,7 +480,7 @@ export default { } }, beforeDestroy(){ //防止重复创建,需要销毁原来的播放器 - console.log('beforeDestroy'); + // console.log('beforeDestroy'); this.player && this.player.dispose(); } };