微信小程序停止其他视频播放当前视频,代码如下所示:

<view class="content">
 <!--首页-->
 <scroll-view class='nav-page'>
  <view class="item-box " wx:for="{{videelsi}}" wx:key="item">
   <!-- 标题层 -->
   <!-- 视频图片层 -->
   <view data-id="{{index}}" class="video-image-box" style="display: {{ _index == index " bindtap="videoPlay">
    <view class="video-cover-box">
     <image class="video-image" src="/UploadFiles/2021-04-02/{{item.cover}}">

css 样式

.content {
 border-top: transparent 1px solid;
 box-sizing: border-box;
 /* height: 100%; */
 width: 100%;
 padding: 0 20rpx;
}
.container{
 border-top: transparent 1px solid;
 /* box-sizing: border-box; */
 /* height: 100%; */
 width: 100%;
}
view {
 vertical-align:middle;
}
.item-box {
 width: 100%;
 margin-top: 40rpx;
 position: relative;
}
.video-title-box{
 height: 70rpx;
 width: 100%;
 background:rgba(0,0,0,1);
opacity:0.2;
 position: absolute;
 bottom: 10rpx;
}
.video-title{
 text-align: center;
 font-size: 30rpx;
 line-height: 70rpx;
font-weight:400;
color:rgba(255,255,255,1);
}
.item-box{
 width: 100%;
 display: -webkit-box; 
 -webkit-box-orient: vertical;
 -webkit-line-clamp:2;
 overflow: hidden;
 text-overflow:ellipsis;
}

.item-box .video-image-box {
 height: 400rpx;
 width: 100%;
 background-repeat: no-repeat;
 background-size: 100% 100%;
 background-position-x: 30rpx;
 position: relative;
}

.video-cover-box{
 height: 100%;
 width: 100%;
 text-align: center;
 line-height: 0rpx;
}
.item-box:first-of-type{
 margin-top: 0rpx;
}
.item-box .video-image-box .video-cover-box .video-image {
 height: 100%;
 width: 100%;
}

.item-box .video {
 height: 300rpx;
 width: 100%;
 margin: 0 30rpx 0 0;
 position: relative;
}

.item-box .video-image-box .video-image-play {
 position: absolute;
 width: 80rpx;
 height: 80rpx;
 top: calc(50% - 40rpx);
 left: calc(50% - 40rpx);
 z-index: 100;
}

js  代码

const app = getApp()

Page({
 data: {
  videoPlay: null,
  videelsi: [],
 },
 onLoad: function () {
  wx.hideShareMenu()
  this.vidoelist()
 },
 vidoelist() {
  app.api.getData(app.data.https + 'wechat/farm/index').then(res => {
   console.log(res)
   this.setData({
    videelsi: res.data.list
   })
  })
 },
 // 点击cover播放,其它视频结束
 videoPlay: function (e) {
  var _index = e.currentTarget.dataset.id
  this.setData({
   _index: _index
  })
  //停止正在播放的视频
  var videoContextPrev = wx.createVideoContext(_index + "")
  videoContextPrev.stop();

  setTimeout(function () {
   //将点击视频进行播放
   var videoContext = wx.createVideoContext(_index + "")
   videoContext.play();
  }, 500)
 }
})

总结

以上所述是小编给大家介绍的微信小程序停止其他视频播放当前视频,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。

更新日志

2024年09月21日