diff --git a/examples/App.vue b/examples/App.vue index e1f0d13..da1e97d 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -1,11 +1,15 @@ @@ -15,7 +19,8 @@ export default { return { options: { source:'//player.alicdn.com/video/aliyunmedia.mp4' - } + }, + show: true } }, @@ -35,7 +40,7 @@ export default { getCurrentTime(){ this.$refs.VueAliplayerV2.getCurrentTime(); - }, + } } } @@ -44,11 +49,16 @@ export default { margin: 0; padding: 0; } +.remove-text{ + text-align: center; + padding: 20px; + font-size: 24px; +} .player-btns{ - width: 800px; - margin: 0 auto; + width: 100%; display: flex; justify-content: space-between; + flex-wrap: wrap; span { margin: 0 auto; display: inline-block; diff --git a/lib/vue-aliplayer-v2.common.js b/lib/vue-aliplayer-v2.common.js index cac1dda..81d4ce6 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=66e79580& +// 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=c72078bc& 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=66e79580& +// CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=template&id=c72078bc& // 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& // @@ -274,14 +274,14 @@ var staticRenderFns = [] init: function init() { var _this3 = this; - var load = true; var linkID = 'aliplayer-min-css'; var scriptID = 'aliplayer-min-js'; var head = document.getElementsByTagName('head'); var html = document.getElementsByTagName('html'); var scriptTag = document.getElementById(scriptID); + var linkIDTag = document.getElementById(linkID); - if (!document.getElementById(linkID)) { + if (!linkIDTag) { var link = document.createElement('link'); link.type = 'text/css'; link.rel = 'stylesheet'; @@ -298,14 +298,12 @@ var staticRenderFns = [] html[0].appendChild(scriptTag); } - scriptTag.addEventListener("load", function () { - _this3.initPlayer(); - - load = false; - }); - - if (!load) { + if (scriptTag && linkIDTag) { this.initPlayer(); + } else { + scriptTag.addEventListener("load", function () { + _this3.initPlayer(); + }); } }, @@ -325,10 +323,11 @@ var staticRenderFns = [] } } - this.config.id = this.id; - this.player = new Aliplayer(this.config, function (player) { - console.log('播放器创建好了。', player); - }); + this.config.id = this.id; // this.player = new Aliplayer(this.config, function(player) { + // // console.log('播放器创建好了',player); + // }); + + this.player = new Aliplayer(this.config); var _loop = function _loop(ev) { _this4.player.on(_this4.events[ev], function (e) { diff --git a/lib/vue-aliplayer-v2.umd.js b/lib/vue-aliplayer-v2.umd.js index cf22750..701b176 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=66e79580& +// 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=c72078bc& 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=66e79580& +// CONCATENATED MODULE: ./packages/AliplayerV2/src/main.vue?vue&type=template&id=c72078bc& // 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& // @@ -283,14 +283,14 @@ var staticRenderFns = [] init: function init() { var _this3 = this; - var load = true; var linkID = 'aliplayer-min-css'; var scriptID = 'aliplayer-min-js'; var head = document.getElementsByTagName('head'); var html = document.getElementsByTagName('html'); var scriptTag = document.getElementById(scriptID); + var linkIDTag = document.getElementById(linkID); - if (!document.getElementById(linkID)) { + if (!linkIDTag) { var link = document.createElement('link'); link.type = 'text/css'; link.rel = 'stylesheet'; @@ -307,14 +307,12 @@ var staticRenderFns = [] html[0].appendChild(scriptTag); } - scriptTag.addEventListener("load", function () { - _this3.initPlayer(); - - load = false; - }); - - if (!load) { + if (scriptTag && linkIDTag) { this.initPlayer(); + } else { + scriptTag.addEventListener("load", function () { + _this3.initPlayer(); + }); } }, @@ -334,10 +332,11 @@ var staticRenderFns = [] } } - this.config.id = this.id; - this.player = new Aliplayer(this.config, function (player) { - console.log('播放器创建好了。', player); - }); + this.config.id = this.id; // this.player = new Aliplayer(this.config, function(player) { + // // console.log('播放器创建好了',player); + // }); + + this.player = new Aliplayer(this.config); var _loop = function _loop(ev) { _this4.player.on(_this4.events[ev], function (e) { diff --git a/lib/vue-aliplayer-v2.umd.min.js b/lib/vue-aliplayer-v2.umd.min.js index 6319289..fbd8f34 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))}},data:function(){return{player:null,config:{id:null,width:"100%",autoplay:!0,cssLink:"https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css",scriptSrc:"https://g.alicdn.com/de/prismplayer/2.8.2/aliplayer-min.js"},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=!0,n="aliplayer-min-css",r="aliplayer-min-js",i=document.getElementsByTagName("head"),o=document.getElementsByTagName("html"),a=document.getElementById(r);if(!document.getElementById(n)){var u=document.createElement("link");u.type="text/css",u.rel="stylesheet",u.href=this.config.cssLink,u.setAttribute("id",n),i[0].appendChild(u)}a||(a=document.createElement("script"),a.type="text/javascript",a.id=r,a.src=this.config.scriptSrc,o[0].appendChild(a)),a.addEventListener("load",(function(){e.initPlayer(),t=!1})),t||this.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];this.config.id=this.id,this.player=new Aliplayer(this.config,(function(e){console.log("播放器创建好了。",e)}));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,s="function"===typeof e?e.options:e;if(t&&(s.render=t,s.staticRenderFns=n,s._compiled=!0),r&&(s.functional=!0),o&&(s._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)},s._ssrRegister=c):i&&(c=u?function(){i.call(this,this.$root.$options.shadowRoot)}:i),c)if(s.functional){s._injectStyles=c;var l=s.render;s.render=function(e,t){return c.call(t),l(e,t)}}else{var f=s.beforeCreate;s.beforeCreate=f?[].concat(f,c):[c]}return{exports:e,options:s}}var s=c(u,i,o,!1,null,null,null),l=s.exports;l.install=function(e){e.component(l.name,l)};var f=l,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}})},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))}},data:function(){return{player:null,config:{id:null,width:"100%",autoplay:!0,cssLink:"https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css",scriptSrc:"https://g.alicdn.com/de/prismplayer/2.8.2/aliplayer-min.js"},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.config.cssLink,u.setAttribute("id",t),r[0].appendChild(u)}o||(o=document.createElement("script"),o.type="text/javascript",o.id=n,o.src=this.config.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];this.config.id=this.id,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,s="function"===typeof e?e.options:e;if(t&&(s.render=t,s.staticRenderFns=n,s._compiled=!0),r&&(s.functional=!0),o&&(s._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)},s._ssrRegister=c):i&&(c=u?function(){i.call(this,this.$root.$options.shadowRoot)}:i),c)if(s.functional){s._injectStyles=c;var l=s.render;s.render=function(e,t){return c.call(t),l(e,t)}}else{var f=s.beforeCreate;s.beforeCreate=f?[].concat(f,c):[c]}return{exports:e,options:s}}var s=c(u,i,o,!1,null,null,null),l=s.exports;l.install=function(e){e.component(l.name,l)};var f=l,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}))}})})); //# sourceMappingURL=vue-aliplayer-v2.umd.min.js.map \ No newline at end of file diff --git a/package.json b/package.json index d99dee0..5644323 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-aliplayer-v2", - "version": "1.0.9", + "version": "1.1.0", "author": "yxs", "description": "感谢每一位开源的开发者. 这是一个基于Alipayer 开发并封装成vue组件的播放器.", "main":"lib/vue-aliplayer-v2.umd.min.js", diff --git a/packages/AliplayerV2/src/main.vue b/packages/AliplayerV2/src/main.vue index bde467a..d26d3f7 100644 --- a/packages/AliplayerV2/src/main.vue +++ b/packages/AliplayerV2/src/main.vue @@ -129,13 +129,13 @@ export default { * 加载Alipayer的SDK */ init(){ - let load = true; const linkID = 'aliplayer-min-css'; const scriptID = 'aliplayer-min-js'; const head = document.getElementsByTagName('head'); const html = document.getElementsByTagName('html'); let scriptTag = document.getElementById(scriptID); - if(!document.getElementById(linkID)) { + let linkIDTag = document.getElementById(linkID); + if(!linkIDTag) { const link = document.createElement('link'); link.type = 'text/css'; link.rel = 'stylesheet'; @@ -151,13 +151,12 @@ export default { html[0].appendChild(scriptTag); } - scriptTag.addEventListener("load", () => { - this.initPlayer(); - load = false; - }); - - if(!load){ + if(scriptTag && linkIDTag){ this.initPlayer(); + } else { + scriptTag.addEventListener("load", () => { + this.initPlayer(); + }); } }, @@ -174,9 +173,10 @@ export default { } } this.config.id = this.id; - this.player = new Aliplayer(this.config, function(player) { - console.log('播放器创建好了。',player); - }); + // this.player = new Aliplayer(this.config, function(player) { + // // console.log('播放器创建好了',player); + // }); + this.player = new Aliplayer(this.config); for(const ev in this.events){ this.player.on(this.events[ev],(e)=>{ // console.log(`object ${this.events[ev]}`,e);