Blame view

ceres-uniapp-master/components/canvasShow/basics/video.vue 2.69 KB
3f535f30   杨鑫   '初始'
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
  <template>
    <div class="videoBox warp" :class="'terminal' + terminal">
      <div class="videoLeftBox">
        <h3>{{componentContent.title}}</h3>
        <div v-html="componentContent.mainBody"></div>
      </div>
      <div class="videoRightBox" v-if="componentContent.coverImg && isPlay">
        <video class="myVideo" id="myVideo" :src="componentContent.videoUrl" enable-danmu danmu-btn controls></video>
      </div>
      <div class="videoCoverBox" v-if="componentContent.coverImg && !isPlay" @click="handlePlayVideo">
        <image :src="componentContent.coverImg" />
      </div>
      <div class="videoRightBox" v-if="!componentContent.coverImg">
        <video class="myVideo" id="myVideo" :src="componentContent.videoUrl" enable-danmu danmu-btn controls></video>
      </div>
      <div class="clear"></div>
  <!--    <div style="width:100vw;height:200px">
        <image :src="componentContent.coverImg" />
      </div>-->
    </div>
  </template>
  
  <script>
  export default {
    name: 'videoBox',
    props: {
      terminal: {
        type: Number,
        default: 4
      },
      componentContent: {
        type: Object
      }
    },
    created(){
      console.log('componentContent',this.componentContent)
    },
    mounted() {
      this.videoContext = uni.createVideoContext('myVideo',this)
    },
    data () {
      return {
        isPlay:false,
        videoContext:null
      }
    },
    methods:{
      handlePlayVideo(){
        this.isPlay = true
        setTimeout(()=>{
          this.videoContext.play()
        },500)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
   .videoBox {
     padding: 20upx 0;
     display: flex;
     justify-content: flex-start;
     align-items: center;
     .videoLeftBox {
       width: 50%;
       padding-right: 10%;
       h3 {
         font-size: 28upx;
         color: #333333;
         margin-bottom: 30upx;
       }
       p {
         color: #333333;
         font-size: 14upx;
         line-height: 30upx;
       }
     }
     .videoRightBox {
       width: 50%;
       video {
         width: 100%;
       }
     }
     .clear {
       clear: both;
     }
   }
   .terminal1,.terminal2,.terminal3{
     &.videoBox{
       display: block;
       .videoLeftBox{
         width: 100%;
         text-align: center;
         margin-bottom: 20upx;
       }
       .videoRightBox {
         width: 100vw;
         height: 56.25vw; //16:9
       }
     }
   }
   .videoCoverBox{
     width: 100vw;
     height: 56.25vw; //16:9
  
     position: relative;
     &:before{
       content: '';
       width: 0rpx;
       height: 0rpx;
       border-left:80rpx solid #fff;
       border-right:50rpx solid transparent;
       border-top:50rpx solid transparent;
       border-bottom:50rpx solid transparent;
      position: absolute;
       top: 50%;
       left: 50%;
       transform: translate(-30%,-50%);
       z-index: 99;
     }
     image{
       width: 100%;
       height: 100%;
     }
   }
  </style>