VueAliplayer.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <template>
  2. <div class="prism-player" :id="playerId" :style="playStyle">
  3. <img v-show="isShowPlay" @click="play()" :src="playIcon" class="btnPlay" />
  4. </div>
  5. </template>
  6. <script>
  7. import image from '../LemonUI/components/message/image.vue';
  8. export default {
  9. components: { image },
  10. name: "Aliplayer",
  11. props: {
  12. source: {
  13. type: String,
  14. default: ""
  15. },
  16. //媒体转码服务的媒体Id。
  17. vid: {
  18. type: String,
  19. default: ""
  20. },
  21. //播放权证
  22. playauth: {
  23. type: String,
  24. default: ""
  25. },
  26. //容器的大小
  27. height: {
  28. type: String,
  29. default: "320px"
  30. },
  31. //容器的大小
  32. width: {
  33. type: String,
  34. default: "100%"
  35. },
  36. //视频的高度大小
  37. videoWidth: {
  38. type: String,
  39. default: "100%"
  40. },
  41. //视频的宽度大小
  42. videoHeight: {
  43. type: String,
  44. default: "320px"
  45. },
  46. //播放器自动加载,目前仅h5可用
  47. preload: {
  48. type: Boolean,
  49. default: false
  50. },
  51. //播放器默认封面图片,请填写正确的图片url地址。需要autoplay为’false’时,才生效
  52. cover: {
  53. type: String,
  54. default: ""
  55. },
  56. //播放内容是否为直播,直播时会禁止用户拖动进度条。
  57. isLive: {
  58. type: Boolean,
  59. default: false
  60. },
  61. //播放器是否自动播放,在移动端autoplay属性会失效。
  62. autoplay: {
  63. type: Boolean,
  64. default: false
  65. },
  66. //播放器自动循环播放。
  67. rePlay: {
  68. type: Boolean,
  69. default: false
  70. },
  71. //指定使用H5播放器。
  72. useH5Prism: {
  73. type: Boolean,
  74. default: false
  75. },
  76. //指定使用Flash播放器。
  77. useFlashPrism: {
  78. type: Boolean,
  79. default: false
  80. },
  81. //H5是否内置播放,有的Android浏览器不起作用。
  82. playsinline: {
  83. type: Boolean,
  84. default: false
  85. },
  86. //显示播放时缓冲图标,默认true。
  87. showBuffer: {
  88. type: Boolean,
  89. default: true
  90. },
  91. //URL 皮肤图片,不建议随意修改该字段,如要修改,请参照皮肤定制。
  92. skinRes: {
  93. type: String,
  94. default: ""
  95. },
  96. skinLayout: {
  97. type: Array,
  98. default: function () {
  99. return []
  100. }
  101. },
  102. //默认为‘hover’。可选的值为:‘click’、‘hover’、‘always’。
  103. controlBarVisibility: {
  104. type: String,
  105. default: "hover"
  106. },
  107. //控制栏自动隐藏时间(ms)
  108. showBarTime: {
  109. type: String,
  110. default: ""
  111. },
  112. /***
  113. * JSON串用于定制性接口参数,目前支持:
  114. 1.“fullTitle”:“测试页面”
  115. 全屏时显示视频标题(仅flash支持)。
  116. 2. “m3u8BufferLength”:“30”
  117. 播放m3u8时加载缓存ts文件长度单位(秒)(仅flash支持)。
  118. 3. “liveStartTime”:“2016/08/17 12:00:00”
  119. 直播开始时间,用于提示直播未开始(仅flash支持)。
  120. 4. “liveOverTime”:“2016/08/17 14:00:00”
  121. 直播结束时间,用于提示直播结束(仅flash支持)。
  122. */
  123. extraInfo: {
  124. type: String,
  125. default: ""
  126. },
  127. /**
  128. *是否允许系统右键菜单显示,默认为false。
  129. */
  130. enableSystemMenu: {
  131. type: Boolean,
  132. default: false
  133. },
  134. /***
  135. *
  136. *指定播放地址格式,只有使用vid的播放方式时支持
  137. 可选值为’mp4’、’m3u8’、’flv’、’mp3’,默认为空,仅H5支持。
  138. * */
  139. format: {
  140. type: String,
  141. default: "mp4"
  142. },
  143. /***
  144. *
  145. * 指定返回音频还是视频,只有使用vid的播放方式时支持。
  146. 可选值为’video’和’audio’,默认为’video’
  147. ‘audio’主要是针对只包含音频的视频格式,比如音频的mp4,仅H5支持。
  148. * */
  149. mediaType: {
  150. type: String,
  151. default: "video"
  152. },
  153. /***
  154. * 指定排序方式,只有使用vid + plauth播放方式时支持。
  155. ‘desc’表示按倒序排序(即:从大到小排序)
  156. ‘asc’表示按正序排序(即:从小到大排序)
  157. 默认值:‘asc’,仅H5支持。
  158. * */
  159. qualitySort: {
  160. type: String,
  161. default: "asc"
  162. },
  163. /***
  164. * 显示视频清晰度,多个用逗号分隔,比如:’FD,LD’,此值是vid对应流清晰度的一个子集,
  165. 取值范围:FD(流畅)LD(标清)SD(高清)HD(超清)OD(原画)2K(2K)4K(4K),仅H5支持。
  166. * */
  167. definition: {
  168. type: String,
  169. default: ""
  170. },
  171. /**
  172. * 默认视频清晰度,此值是vid对应流的一个清晰度,
  173. 取值范围:FD(流畅)LD(标清)SD(高清)HD(超清)OD(原画)2K(2K)4K(4K),仅H5支持。
  174. * */
  175. defaultDefinition: {
  176. type: String,
  177. default: ""
  178. },
  179. /**
  180. * 声明启用同层H5播放器,启用时设置的值为‘h5’
  181. * */
  182. x5_type: {
  183. type: String,
  184. default: "h5"
  185. },
  186. /**
  187. * 声明视频播放时是否进入到TBS的全屏模式,默认为false。
  188. 当需要把视频做为背景时,设置为true
  189. * */
  190. x5_fullscreen: {
  191. type: Boolean,
  192. default: false
  193. },
  194. /**
  195. * 声明视频播在界面上的位置,默认为“center”。
  196. 可选值为:“top”,“center”
  197. * */
  198. x5_video_position: {
  199. type: String,
  200. default: "center"
  201. },
  202. /**
  203. * 声明 TBS 播放器支持的方向,可选值:
  204. landscape:横屏)
  205. portraint:竖屏
  206. landscape
  207. * */
  208. x5_orientation: {
  209. type: String,
  210. default: "portraint"
  211. },
  212. /**
  213. * 声明TBS全屏播放是否横屏,默认值为true。
  214. * */
  215. x5LandscapeAsFullScreen: {
  216. type: String,
  217. default: "true"
  218. },
  219. /**
  220. * 延迟播放时间,单位为秒。
  221. * */
  222. autoPlayDelay: {
  223. type: Number,
  224. default: 0
  225. },
  226. /**
  227. * 延迟播放提示文本
  228. * */
  229. autoPlayDelayDisplayText: {
  230. type: String,
  231. default: "正在转码,请稍后......"
  232. },
  233. /**
  234. * 国际化,默认为‘zh-cn’。
  235. 如果未设置,则采用浏览器语言。
  236. 可选值为‘zh-cn’、‘en-us’或其它值。
  237. * */
  238. language: {
  239. type: String,
  240. default: "zh-cn"
  241. },
  242. /**
  243. * 自定义国际化文本json结构,key的值需要和language属性值对应起来。
  244. 例子:{jp:{Play:”Play”}}
  245. * */
  246. languageTexts: {
  247. type: Object,
  248. default: function () {
  249. return {}
  250. }
  251. },
  252. /**
  253. * flash启用截图功能
  254. * */
  255. snapshot: {
  256. type: Boolean,
  257. default: false
  258. },
  259. /**
  260. * H5设置截图水印。
  261. * */
  262. snapshotWatermark: {
  263. type: Object,
  264. default: function () {
  265. return {}
  266. }
  267. },
  268. /**
  269. * Safari浏览器可以启用Hls插件播放,Safari 11除外。
  270. * */
  271. useHlsPluginForSafari: {
  272. type: Boolean,
  273. default: false
  274. },
  275. /**
  276. * H5播放flv时,设置是否启用播放缓存,只在直播下起作用。
  277. * */
  278. enableStashBufferForFlv: {
  279. type: Boolean,
  280. default: false
  281. },
  282. /**
  283. * H5播放flv时,初始缓存大小,只在直播下起作用。
  284. * */
  285. stashInitialSizeForFlv: {
  286. type: Number,
  287. default: 10
  288. },
  289. /**
  290. * 缓冲多长时间后,提示用户切换低清晰度,默认:20秒。
  291. * */
  292. loadDataTimeout: {
  293. type: Number,
  294. default: 20
  295. },
  296. /**
  297. *最大缓冲超时时间,超过这个时间会有错误提示,默认:60秒。
  298. * */
  299. waitingTimeout: {
  300. type: Number,
  301. default: 60
  302. },
  303. /**
  304. * 直播开始时间,直播时移功能使用,格式为:“2018/01/04 12:00:00”。
  305. * */
  306. liveStartTime: {
  307. type: String,
  308. default: ""
  309. },
  310. /**
  311. * 直播结束时间,直播时移功能使用,格式为:“2018/01/04 12:00:00”。
  312. * */
  313. liveOverTime: {
  314. type: String,
  315. default: ""
  316. },
  317. /**
  318. * 直播可用时移查询地址,详情参见直播时移。
  319. * https://help.aliyun.com/document_detail/65129.html?spm=a2c4g.11186623.2.28.3603bf80LR74sS
  320. * */
  321. liveTimeShiftUrl: {
  322. type: String,
  323. default: ""
  324. },
  325. /**
  326. * flv直播和hls时移切换是,重新创建播放器方法,详情参见直播时移。
  327. * https://help.aliyun.com/document_detail/65129.html?spm=a2c4g.11186623.2.28.3603bf80LR74sS
  328. * */
  329. recreatePlayer: {
  330. type: Function,
  331. default: function () {
  332. }
  333. },
  334. /**
  335. *是否显示检测按钮,默认为true。
  336. * */
  337. diagnosisButtonVisible: {
  338. type: Boolean,
  339. default: true
  340. },
  341. /**
  342. * 禁用进度条的Seek,默认为false,仅Flash支持。
  343. * */
  344. disableSeek: {
  345. type: Boolean,
  346. default: false
  347. },
  348. /**
  349. * 加密类型,播放点播私有加密视频时,设置值为1,默认值为0。
  350. * */
  351. encryptType: {
  352. type: Number,
  353. default: 0
  354. },
  355. /**
  356. * 进度条打点内容数组,详情参见进度条打点。
  357. * [
  358. {offset:0,text:'阿里视频云端到云到端服务的重要一环'},
  359. {offset:10,text:'除了支持点播和直播的基础播放功能外'},
  360. {offset:20,text:'深度融合视频云业务'},
  361. {offset:30,text:'为用户提供简单、快速、安全、稳定的视频播放服务'},
  362. {offset:40,text:'安装播放器Demo进行体验'},
  363. {offset:50,text:'开发人员请点击SDK下载'}
  364. ]
  365. * https://yq.aliyun.com/articles/686043?spm=a2c4g.11186623.2.31.3603bf80LR74sS
  366. * */
  367. progressMarkers: {
  368. type: Array,
  369. default: function () {
  370. return []
  371. }
  372. },
  373. /**
  374. * 点播失败重试次数,默认3次
  375. * */
  376. vodRetry: {
  377. type: Number,
  378. default: 3
  379. },
  380. /**
  381. * 直播播放失败重试次数,默认5次
  382. * */
  383. liveRetry: {
  384. type: Number,
  385. default: 5
  386. },
  387. playStyle: {
  388. type: String,
  389. default: ""
  390. },
  391. aliplayerSdkPath: {
  392. // Aliplayer 代码的路径
  393. type: String,
  394. default: "//g.alicdn.com/de/prismplayer/2.8.2/aliplayer-min.js"
  395. },
  396. },
  397. data() {
  398. return {
  399. playerId: "aliplayer_" + Math.random().toString(36).substr(2),
  400. scriptTagStatus: 0,
  401. isReload: false,
  402. instance: null,
  403. isShowPlay:false,
  404. playIcon:require('@/assets/image/video.png')
  405. };
  406. },
  407. created() {
  408. if (window.Aliplayer !== undefined) {
  409. // 如果全局对象存在,说明编辑器代码已经初始化完成,直接加载编辑器
  410. this.scriptTagStatus = 2;
  411. this.initAliplayer();
  412. } else {
  413. // 如果全局对象不存在,说明编辑器代码还没有加载完成,需要加载编辑器代码
  414. this.insertScriptTag();
  415. }
  416. },
  417. mounted() {
  418. if (window.Aliplayer !== undefined) {
  419. // 如果全局对象存在,说明编辑器代码已经初始化完成,直接加载编辑器
  420. this.scriptTagStatus = 2;
  421. this.initAliplayer();
  422. } else {
  423. // 如果全局对象不存在,说明编辑器代码还没有加载完成,需要加载编辑器代码
  424. this.insertScriptTag();
  425. }
  426. },
  427. methods: {
  428. insertScriptTag() {
  429. const _this = this;
  430. let playerScriptTag = document.getElementById("playerScriptTag");
  431. // 如果这个tag不存在,则生成相关代码tag以加载代码
  432. if (playerScriptTag === null) {
  433. playerScriptTag = document.createElement("script");
  434. playerScriptTag.type = "text/javascript";
  435. playerScriptTag.src = this.aliplayerSdkPath;
  436. playerScriptTag.id = "playerScriptTag";
  437. let s = document.getElementsByTagName("head")[0];
  438. s.appendChild(playerScriptTag);
  439. }
  440. if (playerScriptTag.loaded) {
  441. _this.scriptTagStatus++;
  442. } else {
  443. playerScriptTag.addEventListener("load", () => {
  444. _this.scriptTagStatus++;
  445. playerScriptTag.loaded = true;
  446. _this.initAliplayer();
  447. });
  448. }
  449. _this.initAliplayer();
  450. },
  451. initAliplayer() {
  452. const _this = this;
  453. // scriptTagStatus 为 2 的时候,说明两个必需引入的 js 文件都已经被引入,且加载完成
  454. if (
  455. _this.scriptTagStatus === 2 &&
  456. (_this.instance === null || _this.reloadPlayer)
  457. ) {
  458. _this.instance && _this.instance.dispose();
  459. //document.querySelector("#" + _this.playerId).innerHTML = "";
  460. // Vue 异步执行 DOM 更新,这样一来代码执行到这里的时候可能 template 里面的 script 标签还没真正创建
  461. // 所以,我们只能在 nextTick 里面初始化 Aliplayer
  462. _this.$nextTick(() => {
  463. _this.instance = window.Aliplayer({
  464. id: _this.playerId,
  465. source: _this.source,
  466. vid: _this.vid,
  467. playauth: _this.playauth,
  468. width: _this.width,
  469. height: _this.height,
  470. videoWidth: _this.videoWidth,
  471. videoHeight: _this.videoHeight,
  472. preload: _this.preload,
  473. cover: _this.cover,
  474. isLive: _this.isLive,
  475. autoplay: _this.autoplay,
  476. rePlay: _this.rePlay,
  477. useH5Prism: _this.useH5Prism,
  478. useFlashPrism: _this.useFlashPrism,
  479. playsinline: _this.playsinline,
  480. showBuffer: _this.showBuffer,
  481. skinRes: _this.skinRes,
  482. skinLayout: _this.skinLayout,
  483. controlBarVisibility: _this.controlBarVisibility,
  484. showBarTime: _this.showBarTime,
  485. extraInfo: _this.extraInfo,
  486. enableSystemMenu: _this.enableSystemMenu,
  487. format: _this.format,
  488. mediaType: _this.mediaType,
  489. qualitySort: _this.qualitySort,
  490. definition: _this.definition,
  491. defaultDefinition: _this.defaultDefinition,
  492. x5_type: _this.x5_type,
  493. x5_fullscreen: _this.x5_fullscreen,
  494. x5_video_position: _this.x5_video_position,
  495. x5_orientation: _this.x5_orientation,
  496. x5LandscapeAsFullScreen: _this.x5LandscapeAsFullScreen,
  497. autoPlayDelay: _this.autoPlayDelay,
  498. autoPlayDelayDisplayText: _this.autoPlayDelayDisplayText,
  499. language: _this.language,
  500. languageTexts: _this.languageTexts,
  501. snapshot: _this.snapshot,
  502. snapshotWatermark: _this.snapshotWatermark,
  503. useHlsPluginForSafari: _this.useHlsPluginForSafari,
  504. enableStashBufferForFlv: _this.enableStashBufferForFlv,
  505. stashInitialSizeForFlv: _this.stashInitialSizeForFlv,
  506. loadDataTimeout: _this.loadDataTimeout,
  507. waitingTimeout: _this.waitingTimeout,
  508. liveStartTime: _this.liveStartTime,
  509. liveTimeShiftUrl: _this.liveTimeShiftUrl,
  510. liveShiftSource: _this.liveShiftSource,
  511. recreatePlayer: _this.recreatePlayer,
  512. diagnosisButtonVisible: _this.diagnosisButtonVisible,
  513. disableSeek: _this.disableSeek,
  514. encryptType: _this.encryptType,
  515. progressMarkers: _this.progressMarkers,
  516. vodRetry: _this.vodRetry,
  517. liveRetry: _this.liveRetry,
  518. });
  519. // 绑定事件,当 AliPlayer 初始化完成后,将编辑器实例通过自定义的 ready 事件交出去
  520. _this.instance.on("ready", () => {
  521. this.$emit("ready", _this.instance);
  522. });
  523. _this.instance.on("play", () => {
  524. this.isShowPlay=false;
  525. this.$emit("play", _this.instance);
  526. });
  527. _this.instance.on("pause", () => {
  528. this.$emit("pause", _this.instance);
  529. });
  530. _this.instance.on("ended", () => {
  531. this.isShowPlay=true;
  532. this.$emit("ended", _this.instance);
  533. });
  534. _this.instance.on("liveStreamStop", () => {
  535. this.$emit("liveStreamStop", _this.instance);
  536. });
  537. _this.instance.on("m3u8Retry", () => {
  538. this.$emit("m3u8Retry", _this.instance);
  539. });
  540. _this.instance.on("hideBar", () => {
  541. this.$emit("hideBar", _this.instance);
  542. });
  543. _this.instance.on("waiting", () => {
  544. this.$emit("waiting", _this.instance);
  545. });
  546. _this.instance.on("snapshoted", () => {
  547. this.$emit("snapshoted", _this.instance);
  548. });
  549. _this.instance.on("timeupdate", () => {
  550. this.$emit("timeupdate", _this.instance);
  551. });
  552. _this.instance.on("requestFullScreen", () => {
  553. this.$emit("requestFullScreen", _this.instance);
  554. });
  555. _this.instance.on("cancelFullScreen", () => {
  556. this.$emit("cancelFullScreen", _this.instance);
  557. });
  558. _this.instance.on("error", () => {
  559. this.$emit("error", _this.instance);
  560. });
  561. _this.instance.on("startSeek", () => {
  562. this.$emit("startSeek", _this.instance);
  563. });
  564. _this.instance.on("completeSeek", () => {
  565. this.$emit("completeSeek", _this.instance);
  566. });
  567. });
  568. }
  569. },
  570. /**
  571. * 播放视频
  572. */
  573. play: function () {
  574. this.instance.play();
  575. },
  576. /**
  577. * 暂停视频
  578. */
  579. pause: function () {
  580. this.instance.pause();
  581. },
  582. /**
  583. * 重播视频
  584. */
  585. replay: function () {
  586. this.instance.replay();
  587. },
  588. /**
  589. * 跳转到某个时刻进行播放
  590. * @argument time 的单位为秒
  591. */
  592. seek: function (time) {
  593. this.instance.seek(time);
  594. },
  595. /**
  596. * 获取当前时间 单位秒
  597. */
  598. getCurrentTime: function () {
  599. return this.instance.getCurrentTime();
  600. },
  601. /**
  602. *获取视频总时长,返回的单位为秒
  603. * @returns 返回的单位为秒
  604. */
  605. getDuration: function () {
  606. return this.instance.getDuration();
  607. },
  608. /**
  609. 获取当前的音量,返回值为0-1的实数ios和部分android会失效
  610. */
  611. getVolume: function () {
  612. return this.instance.getVolume();
  613. },
  614. /**
  615. 设置音量,vol为0-1的实数,ios和部分android会失效
  616. */
  617. setVolume: function (vol) {
  618. this.instance.setVolume(vol);
  619. },
  620. /**
  621. *直接播放视频url,time为可选值(单位秒)目前只支持同种格式(mp4/flv/m3u8)之间切换暂不支持直播rtmp流切换
  622. *@argument url 视频地址
  623. *@argument time 跳转到多少秒
  624. */
  625. loadByUrl: function (url, time) {
  626. this.instance.loadByUrl(url, time);
  627. },
  628. /**
  629. * 设置播放速度
  630. *@argument speed 速度
  631. */
  632. setSpeed: function (speed) {
  633. this.instance.setSpeed(speed);
  634. },
  635. /**
  636. * 设置播放器大小w,h可分别为400px像素或60%百分比chrome浏览器下flash播放器分别不能小于397x297
  637. *@argument w 播放器宽度
  638. *@argument h 播放器高度
  639. */
  640. setPlayerSize: function (w, h) {
  641. this.instance.setPlayerSize(w, h);
  642. },
  643. /**
  644. *目前只支持H5播放器。
  645. 暂不支持不同格式视频间的之间切换。
  646. 暂不支持直播rtmp流切换。
  647. */
  648. replayByVidAndPlayAuth: function (vid, accId, accSecret, stsToken, authInfo, domainRegion) {
  649. this.instance.replayByVidAndPlayAuth(vid, accId, accSecret, stsToken, authInfo, domainRegion);
  650. },
  651. /***
  652. * 重新设置vid和权限,目前只支持H5播放器。
  653. 暂不支持不同格式视频间的之间切换。
  654. 暂不支持直播rtmp流切换。
  655. * @param vid 视频ID
  656. * @param playauth 播放权限
  657. */
  658. replayByVidAndAuthInfo: function (vid, playauth) {
  659. this.instance.replayByVidAndAuthInfo(vid, playauth);
  660. },
  661. /**
  662. * 目前只支持HTML5界面上的重载功能,暂不支持直播rtmp流切换m3u8)之间切换,暂不支持直播rtmp流切换
  663. *@argument vid 视频id
  664. *@argument playauth 播放凭证
  665. */
  666. reloaduserPlayInfoAndVidRequestMts: function (vid, playauth) {
  667. this.instance.reloaduserPlayInfoAndVidRequestMts(vid, playauth);
  668. },
  669. /***
  670. *设置截图参数
  671. * @param width 宽度
  672. * @param height 高度
  673. * @param rate 截图质量
  674. */
  675. setSanpshotProperties: function (width, height, rate) {
  676. this.instance.setSanpshotProperties(width, height, rate);
  677. },
  678. /**
  679. * 设置封面地址
  680. * @param cover 封面地址
  681. */
  682. setCover: function (cover) {
  683. this.instance.setCover(cover);
  684. },
  685. reloadPlayer: function () {
  686. this.isReload = true;
  687. this.initAliplayer();
  688. this.isReload = false;
  689. }
  690. }
  691. };
  692. </script>
  693. <style>
  694. @import url(//g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css);
  695. </style>
  696. <style scoped>
  697. .btnPlay {
  698. /* width: 40px;
  699. height: 40px;
  700. -webkit-box-align: center;
  701. -ms-flex-align: center;
  702. align-items: center;
  703. -webkit-box-pack: center;
  704. -ms-flex-pack: center;
  705. justify-content: center;
  706. z-index: 10;
  707. position: absolute;
  708. left: calc(50% - 20px);
  709. top: calc(50% - 30px); */
  710. z-index: 10;
  711. background: rgba(0,0,0,0);
  712. width: 64px;
  713. height: 64px;
  714. position: absolute;
  715. left: 50%;
  716. top: 50%;
  717. -ms-transform: translate(-50%,-50%);
  718. transform: translate(-50%,-50%);
  719. }
  720. </style>