视频组件,第一个不暂停的话下一个就无法正常播放
发布于 6 年前 作者 hanping 1268 次浏览 来自 问答
  • 当前 Bug 的

表现(可附上截图)

  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

视频组件,第一个不暂停的话下一个就无法正常播放

Page({

data: {

items: [],

allspurl: [],

currentTab: ‘0’,

id:’’,

fspurl:’’,

fspid:’’,

keyy: ‘0’,

allspid:[],

plr:[],

plsj:[],

plnr:[],

plhf:[],

fsdpl:’’

},

onLoad: function () {

this.setData({ id: wx.getStorageSync(‘id’) })

this.setData({ fspid: wx.getStorageSync(‘fspid’) })

this.getfspurl()

this.getallspm()

this.getallspurl()

this.getallspid()

this.getplr(this.data.fspid)

this.getplsj(this.data.fspid)

this.getplnr(this.data.fspid)

this.getplhf(this.data.fspid)

wx.setNavigationBarTitle({

title: getApp().globalData.gbkcm//页面标题为路由参数

})

},

xzsp:function(e){

var index = parseInt(e.currentTarget.dataset.index);

this.setData({ fspurl: this.data.allspurl[index] })

this.setData({ fspid: this.data.allspid[index] })

this.setData({ keyy: index })

this.videoContext = wx.createVideoContext(’{{keyy}}’)

this.getplr(this.data.fspid)

this.getplsj(this.data.fspid)

this.getplnr(this.data.fspid)

this.getplhf(this.data.fspid)

},

plf: function (e) { this.data.fsdpl = e.detail.value},

anfspl:function(){

if (this.data.fsdpl.length==0){

wx.showToast({

title: ‘请输入评论内容’,

icon: ‘none’,

duration: 2000//持续的时间

})

}else{

var that = this

wx.request({

url: getApp().globalData.gburl +“fspl/” +that.data.id +’?index=’+this.data.fspid+’&&plnr=’+that.data.fsdpl+’&&num=’+getApp().globalData.gbnum,

method: ‘POST’,

success: function (res) {

if (res.data == 1) {

wx.showToast({

title: ‘发送成功’,

icon: ‘none’,

duration: 2000//持续的时间

})}

}

})

}

},

getallspid: function () {

var that = this

wx.request({

url: http://m.cn/allspid/ + that.data.id,

method: ‘GET’,

success: function (res) {

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.allspid[i] = res.data[i];

that.setData({

allspid: that.data.allspid

})

}

}

})

},

getallspurl: function () {

var that = this

wx.request({

url: http://m.cn/allspurl/ + that.data.id,

method: ‘GET’,

success: function (res) {

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.allspurl[i] = res.data[i];

that.setData({

allspurl: that.data.allspurl

})

}

}

})

},

getplr: function (spid) {

var that = this

wx.request({

url: http://m.cn/plr/ + that.data.id +’?index=’+spid,

method: ‘GET’,

success: function (res) {

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.plr[i] = res.data[i];

that.setData({

plr: that.data.plr

})

}

}

})

},

getplsj: function (spid) {

var that = this

wx.request({

url: http://m.cn/plsj/ + that.data.id + ‘?index=’+spid ,

method: ‘GET’,

success: function (res) {

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.plsj[i] = res.data[i];

that.setData({

plsj: that.data.plsj

})

}

}

})

},

getplnr: function (spid) {

var that = this

wx.request({

url: http://m.cn/plnr/ + that.data.id + ‘?index=’+spid,

method: ‘GET’,

success: function (res) {

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.plnr[i] = res.data[i];

that.setData({

plnr: that.data.plnr

})

}

}

})

},

getplhf: function (spid) {

var that = this

wx.request({

url: http://m.cn/plhf/ + that.data.id + ‘?index=’ + spid,

method: ‘GET’,

success: function (res) {

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.plhf[i] = res.data[i];

that.setData({

plhf: that.data.plhf

})

}

}

})

},

getallspm: function () {

var that = this;

wx.request({

url: http://m.cn/allspm/+that.data.id,

method: ‘GET’,

success: function (res) {

for (var i = 0, len = res.data.length; i < len; i++) {

that.data.items[i] = res.data[i];

that.setData({

items: that.data.items

})

}

}

})

},

bindChange: function (e) {

var that = this;

that.setData({ currentTab: e.detail.current });

},

switchNav: function (e) {

var page = this;

var index = e.target.dataset.current;

if (this.data.currentTab == index) {

return false;

} else {

page.setData({ currentTab: index });

}

},

onReady: function (res) {

this.videoContext = wx.createVideoContext(’{{keyy}}’)

},

videoErrorCallback: function (e) {

console.log(‘视频错误信息:’);

console.log(e.detail.errMsg);

},

onPullDownRefresh: function () {

wx.showNavigationBarLoading() //在标题栏中显示加载

this.setData({keyy:0})

this.onLoad()  //模拟加载

setTimeout(function () {// complete

wx.hideNavigationBarLoading() //完成停止加载

wx.stopPullDownRefresh() //停止下拉刷新

}, 800);

},

getfspurl:function(){

var that=this

wx.request({

url: http://m.cn/fspurl/ + this.data.id,

method: ‘GET’,

success: function (res) {

if (res.data) {

that.setData({ fspurl: res.data })

}

else {

wx.showToast({

title: ‘该课程暂无视频’,

icon: ‘none’,

duration: 2000

})

wx.setStorage({

key: “fspurl”,

data: null

})

}

}

})

}

})

wxml

<view class=“videorq”>

<video id="{{keyy}}" src="{{fspurl}}" binderror=“videoErrorCallback” custom-cache="{{false}}"></video>

</view>

<view class=“menu”>

<view class="{{currentTab==0?‘select’:‘default’}}" data-current=“0” bindtap=“switchNav”>视频列表</view>

<view class="{{currentTab==1?‘select’:‘default’}}" data-current=“1” bindtap=“switchNav”>评论</view>

</view>

<view class=“line”>

</view>

<swiper current="{{currentTab}}" style=“height:1800px;” bindchange=“bindChange”>

<swiper-item>  <include src=“shipin.wxml” />   </swiper-item>

<swiper-item>  <include src=“pinglun.wxml” />   </swiper-item>  

</swiper>

shipin.wxml

<view  class=“tr” wx:for = “{{items}}” wx:for-index=“index” wx:for-item=“item” wx:key="" data-index=’{{index}}’ style=’{{keyy==index?“color:#05CF8C;”:""}}'bindtap=‘xzsp’>  

<text class=“td” >{{item.name}}</text>

</view >

1 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

回到顶部