lookShipin.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view id="player-con"></view>
  3. </template>
  4. <script setup>
  5. import {
  6. videoPolicy,
  7. getVideoAuth,
  8. getVideoRefresh
  9. } from "@/api/shipin.js"
  10. import {
  11. onLoad,
  12. onReady
  13. } from '@dcloudio/uni-app';
  14. import {
  15. ref,
  16. reactive
  17. } from "vue"
  18. let videoUrl = 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4'
  19. let pageData = reactive({
  20. type: '',
  21. partUrl: '',
  22. downloadUrl: '',
  23. videoId: '',
  24. uploadAddress: '',
  25. uploadAuth: '',
  26. signature: '',
  27. playauth: '',
  28. })
  29. onReady(() => {
  30. getPlayAuth()
  31. }),
  32. onLoad(() => {
  33. })
  34. // function getVideoId(){
  35. // let req ={
  36. // fileName:videoUrl,
  37. // title:"测试视频"
  38. // }
  39. // videoPolicy(req).then(res=>{
  40. // pageData.videoId = res.data.videoId
  41. // getPlayAuth()
  42. // })
  43. // }
  44. function getPlayAuth() {
  45. let req = {
  46. videoId: 'b997f16cb9cb474cb93526cff77d8801'
  47. }
  48. getVideoAuth(req).then(res => {
  49. pageData.playauth = res.data
  50. playAli()
  51. })
  52. }
  53. function playAli() {
  54. let configData = {
  55. "id": "player-con",
  56. "vid": 'b997f16cb9cb474cb93526cff77d8801',
  57. "playauth": pageData.playauth,
  58. "qualitySort": "asc",
  59. "format": "m3u8",
  60. "mediaType": "video",
  61. "encryptType": 1,
  62. "width": '100%',
  63. progressMarkers: [{
  64. offset: 30,
  65. isCustomized: true,
  66. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  67. title: 'test title',
  68. describe: 'test string',
  69. }, {
  70. offset: 50,
  71. isCustomized: true,
  72. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  73. title: 'test title',
  74. describe: 'test string',
  75. }, {
  76. offset: 150,
  77. isCustomized: true,
  78. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  79. title: 'test title',
  80. describe: 'test string',
  81. }, {
  82. offset: 120,
  83. isCustomized: true,
  84. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  85. title: 'test title',
  86. describe: 'test string',
  87. }],
  88. "height": '500px',
  89. "autoplay": false,
  90. "isLive": false,
  91. "rePlay": false,
  92. "playsinline": true,
  93. "preload": false,
  94. "controlBarVisibility": "hover",
  95. "useH5Prism": true
  96. }
  97. var player = new Aliplayer(configData, function(player) {
  98. console.log('The player is created.')
  99. });
  100. }
  101. </script>