lookShipin.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view id="player-con"></view>
  3. </template>
  4. <script module="aa" lang="renderjs">
  5. //#ifdef H5
  6. import {
  7. videoPolicy,
  8. getVideoAuth,
  9. getVideoRefresh
  10. } from "@/api/shipin.js"
  11. //#endif
  12. //#ifdef APP-PLUS
  13. const { videoPolicy,getVideoAuth,getVideoRefresh} = require("../../api/shipin.js")
  14. //#endif
  15. const loadWebPlayerSDK = async () => {
  16. return new Promise((resolve, reject) => {
  17. const s_tag = document.createElement('script'); // 引入播放器js
  18. s_tag.type = 'text/javascript';
  19. s_tag.src = 'https://g.alicdn.com/de/prismplayer/2.9.6/aliplayer-min.js';
  20. s_tag.charset = 'utf-8';
  21. s_tag.onload = () => {
  22. resolve();
  23. }
  24. document.body.appendChild(s_tag);
  25. const l_tag = document.createElement('link'); // 引入播放器css
  26. l_tag.rel = 'stylesheet';
  27. l_tag.href = 'https://g.alicdn.com/de/prismplayer/2.9.6/skins/default/aliplayer-min.css';
  28. document.body.appendChild(l_tag);
  29. });
  30. }
  31. export default {
  32. data() {
  33. return {
  34. pageData: {
  35. playauth: ''
  36. }
  37. };
  38. },
  39. mounted() {
  40. console.log(111111)
  41. loadWebPlayerSDK().then(() => {
  42. // this.getPlayAuth()
  43. this.playAli()
  44. }).catch((e) => {
  45. console.log("加载播放器SDK失败", e);
  46. });
  47. },
  48. methods: {
  49. getPlayAuth() {
  50. let req = {
  51. videoId: 'b997f16cb9cb474cb93526cff77d8801'
  52. }
  53. getVideoAuth(req).then(res => {
  54. this.pageData.playauth = res.data
  55. this.playAli()
  56. })
  57. },
  58. playAli() {
  59. let configData = {
  60. "id": "player-con",
  61. "vid": 'b997f16cb9cb474cb93526cff77d8801',
  62. "playauth": this.pageData.playauth,
  63. "qualitySort": "asc",
  64. "format": "m3u8",
  65. "mediaType": "video",
  66. "encryptType": 1,
  67. "width": '100%',
  68. progressMarkers: [{
  69. offset: 30,
  70. isCustomized: true,
  71. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  72. title: 'test title',
  73. describe: 'test string',
  74. }, {
  75. offset: 50,
  76. isCustomized: true,
  77. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  78. title: 'test title',
  79. describe: 'test string',
  80. }, {
  81. offset: 150,
  82. isCustomized: true,
  83. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  84. title: 'test title',
  85. describe: 'test string',
  86. }, {
  87. offset: 120,
  88. isCustomized: true,
  89. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  90. title: 'test title',
  91. describe: 'test string',
  92. }],
  93. "height": '500px',
  94. "autoplay": false,
  95. "isLive": false,
  96. "rePlay": false,
  97. "playsinline": true,
  98. "preload": false,
  99. "controlBarVisibility": "hover",
  100. "useH5Prism": true
  101. }
  102. var player = new Aliplayer(configData, function(player) {
  103. console.log('The player is created.')
  104. });
  105. }
  106. }
  107. }
  108. </script>