3328350766
6 天以前 761eb03d6b3bebd0b197179564c84d89d3d12a0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<template>
  <div
    style="width: 100%; height: 100%"
    class="bs-design-wrap"
  >
    <video-player
      ref="videoPlayer1"
      :options="videoOptions"
      class="vjs-custom-skin videoPlayer"
      :playsinline="true"
    />
  </div>
</template>
<script>
import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'videojs-contrib-hls'
import { refreshComponentMixin } from 'data-room-ui/js/mixins/refreshComponent'
export default {
  name: 'Video',
  components: { videoPlayer },
  mixins: [refreshComponentMixin],
  props: {
    // 卡片的属性
    config: {
      type: Object,
      default: () => ({})
    }
  },
  computed: {},
  beforeDestroy () {
    this.$refs.videoPlayer1.dispose()
  },
  data () {
    return {
      // TODO 这里介绍各个参数的意义
      videoOptions: {
        live: true,
        // 浏览器准备好时开始回放
        autoplay: false,
        // true:默认视频播放无声音,需要手动开启声音
        muted: false,
        // 播放速度
        playbackRates: [0.5, 1.0, 1.5, 2.0],
        // 语言
        language: 'zh-CN',
        // 当true时,播放器将按比例缩放以适应其容器
        fluid: true,
        // 无法播放时提示信息
        notSupportedMessage: '该视频无法正常播放',
        // 纵横比或屏幕高宽比
        aspectRatio: '16:9',
        controlBar: {
          timeDivider: true,
          durationDisplay: true,
          remainingTimeDisplay: true,
          // 全屏按钮
          fullscreenToggle: true
        },
        // 播放器宽度,测试无效
        // width: 100,
        // 视频封面图
        poster: this.config.customize.posterUrl,
        sources: [
          {
            // 流配置,数组形式,会根据兼容顺序自动切换
            type: this.config.customize.videoType,
            src: this.config.customize.videoUrl
          }
        ]
      },
      dataForm: {
        script: ''
      }
    }
  },
 
  watch: {},
  mounted () {},
  methods: {
    // 由于静态组件没有混入公共函数,所以需要定义一个changeStyle方法,以免报错
    changeStyle (config) {
      this.videoOptions.sources.type = config.customize.videoType
      this.videoOptions.sources.type = config.customize.videoUrl
      this.videoOptions.poster = config.customize.posterUrl
    }
  }
}
</script>
 
<style lang="scss" scoped>
.bs-design-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: transparent;
  border-radius: 4px;
  box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
 
  .videoPlayer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
  }
}
 
/*滚动条样式*/
::v-deep ::-webkit-scrollbar {
  width: 4px;
  border-radius: 4px;
  height: 4px;
}
 
::v-deep ::-webkit-scrollbar-thumb {
  background: #dddddd !important;
  border-radius: 10px;
}
::v-deep .video-js .vjs-big-play-button {
  z-index: 100;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 4em;
}
</style>