Index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div id="app-effect-video">
  3. <div class="one-block-1">
  4. <span>
  5. 1. 视频播放
  6. </span>
  7. </div>
  8. <!-- <div class="one-block-2">
  9. <a-button @click="selectFile()"> 打开 / 浏览 </a-button>
  10. </div> -->
  11. <div class="one-block-2">
  12. <div id="video-player"></div>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import Player from 'xgplayer'
  18. import { ipcApiRoute } from '@/api/main'
  19. export default {
  20. data() {
  21. return {
  22. fileUrl: '',
  23. p: {},
  24. op: {
  25. id: 'video-player',
  26. volume: 0.3,
  27. url:'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-360p.mp4',
  28. poster: "//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/byted-player-videos/1.0.0/poster.jpg",
  29. playsinline: false,
  30. danmu: {
  31. comments: [
  32. {
  33. duration: 15000,
  34. id: '1',
  35. start: 3000,
  36. txt: '这是一个弹幕',
  37. style: { //弹幕自定义样式
  38. color: '#ff9500',
  39. fontSize: '20px',
  40. border: 'solid 1px #ff9500',
  41. borderRadius: '50px',
  42. padding: '5px 11px',
  43. backgroundColor: 'rgba(255, 255, 255, 0.1)'
  44. }
  45. }
  46. ],
  47. area: {
  48. start: 0,
  49. end: 1
  50. }
  51. },
  52. },
  53. };
  54. },
  55. mounted () {
  56. this.init();
  57. },
  58. methods: {
  59. init () {
  60. //require('E:/video/nos_mp4_2021_05_30_sga9a3cj7_shd.mp4')
  61. this.p = new Player(this.op);
  62. },
  63. selectFile () {
  64. const params = {}
  65. this.$ipc.invoke(ipcApiRoute.selectFile, params).then(res => {
  66. console.log('res:', res)
  67. if (res) {
  68. this.fileUrl = res;
  69. this.p.start(self.fileUrl);
  70. } else {
  71. this.$message.warning('请选择视频');
  72. }
  73. })
  74. },
  75. }
  76. };
  77. </script>
  78. <style lang="less" scoped>
  79. #app-effect-video {
  80. padding: 0px 10px;
  81. text-align: left;
  82. width: 100%;
  83. .one-block-1 {
  84. font-size: 16px;
  85. padding-top: 10px;
  86. }
  87. .one-block-2 {
  88. padding-top: 10px;
  89. }
  90. }
  91. </style>