最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序中的video視頻實(shí)現(xiàn) 自定義播放按鈕、封面圖、視頻封面上文案

 更新時(shí)間:2020年01月02日 13:48:13   作者:我想要兩顆西柚i。  
這篇文章主要介紹了微信小程序中的video視頻實(shí)現(xiàn) 自定義播放按鈕、封面圖、視頻封面上文案,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

效果圖展示:  

實(shí)現(xiàn)方法:

在video中添加一個(gè)cover-view,在cover-view寫兩個(gè)cover-image,一個(gè)用來存儲(chǔ)封面圖、一個(gè)用來存放播放按鈕,同級寫一個(gè)cover-view用來完成封面上的文字,設(shè)置絕對定位,水平垂直居中,在播放按鈕上添加點(diǎn)擊事件,點(diǎn)擊之后隱藏cover-view,最后在監(jiān)聽視頻結(jié)束事件,重新填充封面跟播放按鈕就可以了。

代碼:

<video id="myVideo" src="{{videoSrc}}" enable-danmu controls show-fullscreen-btn show-center-play-btn="{{false}}" auto-pause-if-navigate auto-pause-if-open-native show-play-btn object-fit="fill" bindpause="bindpause" bindended="bindended" >
   <cover-view class="video_cover" wx:if="{{isShow}}" bindtap="bindplay">
    <cover-image src="{{videoCoverImg}}" mode="widthFix"></cover-image>
    <cover-image src="{{videoPlayIcon}}" mode="widthFix" class="video_play_icon"></cover-image>
    <cover-view class="video_bg_black">
     <cover-view class="video_cover_txt">
      <cover-view>
       <cover-view class="video_txt">1天1元,開通VIP</cover-view>
       <cover-view class="video_txt">更多優(yōu)質(zhì)視頻等你來解鎖</cover-view>
      </cover-view>
      <cover-image src="{{videoLockIcon}}" class="video_icon_lock" mode="widthFix"></cover-image>
     </cover-view>
    </cover-view>
   </cover-view>
</video>
 
Page({
 data: {
  isShow:true,
  videoSrc:'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400',  // 視頻
  videoCoverImg:'http://img5.imgtn.bdimg.com/it/u=1672477765,2527992874&fm=26&gp=0.jpg',  // 視頻封面圖
  videoPlayIcon:'http://39.105.134.221:8080/test/source1.png', // 視頻播放icon
  videoLockIcon:'http://39.105.134.221:8080/test/source2.png',  // 視頻播放鎖
 },
 onReady: function () {
  this.videoContext = wx.createVideoContext('myVideo')
 },
 // 點(diǎn)擊封面自定義播放按鈕時(shí)觸發(fā)
 bindplay() {
  this.setData({
   isShow:false
  })
  this.videoContext.play();
  console.log('play')
 },
 // 監(jiān)聽播放到末尾時(shí)觸發(fā)
 bindended(){
  console.log('bindended')
  this.setData({
   isShow: true
  })
  this.videoContext.ended();
 },
 // 監(jiān)聽暫停播放時(shí)觸發(fā)
 bindpause(){
  console.log('pause')
 }
})
 
.video_cover{
 width:100%;
 height:100%;
 position:relative;
}
.video_play_icon{
 position:absolute;
 left:50%;
 top:50%;
 transform:translate(-50%,-50%);
 width:40px;
 height:40px;
 z-index:5
}
.video_bg_black{
 position:absolute;
 left:0;
 top:0;
 bottom:0;
 right:0;
 background:rgba(0,0,0,.5);
}
.video_cover_txt{
 display:flex;
 justify-content: flex-end;
 align-items: center;
 text-align:right;
 color: #fff;
 font-size: 28rpx;
 margin-top: 35rpx;
 height: 90rpx;
}
.video_icon_lock{
 width:30rpx;
 height: auto;
 margin:0 30rpx;
}
.video_txt{
 margin:10rpx auto;
}

總結(jié)

以上所述是小編給大家介紹的微信小程序中的video視頻實(shí)現(xiàn) 自定義播放按鈕、封面圖、視頻封面上文案,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

最新評論

通化市| 蓝山县| 波密县| 长治市| 西华县| 亚东县| 乐东| 邯郸县| 沙雅县| 碌曲县| 大竹县| 五河县| 双辽市| 兴义市| 炉霍县| 抚顺市| 密云县| 美姑县| 东海县| 深水埗区| 明溪县| 新昌县| 庆城县| 嘉祥县| 宁蒗| 万载县| 永仁县| 睢宁县| 阳新县| 滦南县| 建宁县| 衡阳市| 泾川县| 铜鼓县| 崇文区| 万荣县| 芒康县| 达日县| 山阳县| 锡林浩特市| 唐海县|