欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

微信小程序多音頻播放進度條問題

真的腦子疼,小程序的音頻組件居然沒有進度控制的功能,網(wǎng)上的方法又很少,邏輯通了就好寫了。

成都創(chuàng)新互聯(lián)主要從事成都網(wǎng)站設計、網(wǎng)站制作、網(wǎng)頁設計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務。立足成都服務臨淄,10年網(wǎng)站建設經(jīng)驗,價格優(yōu)惠、服務專業(yè),歡迎來電咨詢建站服務:028-86922220

1.所有音頻播放、停止按鈕使用狀態(tài)切換控制
2.當點擊某個音頻播放時,首先將所有音頻的狀態(tài)置為停止狀態(tài),然后將當前音頻置為播放狀態(tài)
3.滾動條插件配合音頻控件一起使用
4.播放狀態(tài)時滾動條的長度隨音頻進度變化而變化,時間也要顯示
5.拖動滾動條時,音頻的當前時間隨滾動條變化而變化

微信小程序多音頻播放進度條問題

1.wxml

<text class="left_text">{{item.currentProcess}}</text>
        <slider class="slider_middle" bindchange="changeSlide" bindtouchstart="start" bindtouchend="end" max="{{item.totalProcessNum}}" min="0" value="{{item.currentProcessNum}}" disabled="{{item.canSlider}}" block-size  ="18" data-index="{{index}}"></slider>
        <text class="right_text">{{item.totalProcess}}</text>
        <image class="audio_btn" wx:if="{{!item.showAudio}}" src="../assets/play.png" data-src="{{item.src}}" bindtap="playAudio" data-index = "{{index}}"></image>
        <image class="audio_btn" wx:else src="../assets/pause.png" bindtap="pauseAudio" data-index = "{{index}}"></image>

2.js

 videoControl(e) {//控制視頻播放,需求更改后暫時無用
  let src = e.currentTarget.dataset.src
  let img = e.currentTarget.dataset.post
  let data = this.data.cc
  let that = this
  if (this.data.innerAudioContext2){
   that.data.innerAudioContext2.stop()
  }
  if (this.data.innerAudioContext) {
   that.data.innerAudioContext.stop()
   that.setUser(that.data.oldid, false)
  }
  for(var i = 0;i<data.length;i++){
   if (data[i].type == '2'){
    data[i].play = true
   }
  }
  this.setData({
   cc:data
  })
  if(this.data.type){
   wx.navigateTo({
    url: '/pages/record/record?cid=' + this.data.cid + '&src=' + src + '&img=' + img + '&type="share"'
   })
  }else{
   wx.navigateTo({
    url: '/pages/record/record?cid=' + this.data.cid + '&src=' + src + '&img=' + img
   })
  }
 },
 audioControl(e) {//控制課程音頻播放,需求更改后暫時無用
  let index = e.currentTarget.dataset.index
  let that = this
  let data = this.data.cc
  if (this.data.innerAudioContext) {
   that.data.innerAudioContext.stop()
   that.setUser(that.data.oldid, false)
  }
   for (var i = 0; i < data.length; i++) {
    if (data[i].type == '2' && i != index) {
     data[i].play = true
    } else if (data[i].type == '2') {
     data[i].play = false
    } if (data[i].type == '3') {
     data[i].play = true
    } 
   }
  if (!that.data.innerAudioContext2) {//第一次點擊音頻
   that.data.innerAudioContext2 = wx.createInnerAudioContext();
   that.data.innerAudioContext2.src = e.currentTarget.dataset.srcs
   that.data.innerAudioContext2.play()
   that.data.innerAudioContext2.onPlay(()=>{
   })
   that.data.innerAudioContext2.onStop(() => {
   })
   that.setData({//記錄當前點擊項和上次點擊項
    newid2: e.currentTarget.dataset.index,
    oldid2: that.data.newid2 ? that.data.newid2 : index
   })  
  } else {//非第一次點擊
   let old = that.data.newid2
   that.setData({
    newid2: index,
    oldid2: old
   })
   if (that.data.oldid2 != index ) {
    that.data.innerAudioContext2.stop()
    that.data.innerAudioContext2.src = e.currentTarget.dataset.srcs
    that.data.innerAudioContext2.play()
   }else{
    if (that.data.innerAudioContext2.paused){
     that.data.innerAudioContext2.stop()
     that.data.innerAudioContext2.src = e.currentTarget.dataset.srcs
     that.data.innerAudioContext2.play()
    }else{
     that.data.innerAudioContext2.stop() 
     for (var i = 0; i < data.length; i++) {
      data[i].play = true
     }
    }
   }
  }
  this.setData({
   cc: data
  })
 },
 playAudio(e){//帶滾動條多個音頻處理問題
  let that = this
  let arr = that.data.cc
  let index = e.currentTarget.dataset.index
  if (that.data.audio) {//將所有的音頻停止
   that.data.audio.pause()
  }
  for(let i=0;i<arr.length;i++){//將所有的音頻置為停止狀態(tài)
   that.setAudioType(i,false,true)
  }
  that.setAudioType(index,true,false)//將當前音頻置為播放狀態(tài)
  that.data.audio = wx.getBackgroundAudioManager();//初始化音頻并播放
  that.data.audio.src = e.currentTarget.dataset.src
  that.data.audio.title = '泰格英語'
  that.data.audio.epname = '泰格英語'
  that.data.audio.autoplay = true
  that.data.audio.play();
  //音頻開始播放的時間
  if (arr[index].currentProcessNum != 0){
   that.data.audio.startTime = arr[index].currentProcessNum
  }
  //音頻自然播放結(jié)束
  that.data.audio.onEnded(function name(params) {
   that.setCurrent(index, "00:00", 0)
   that.setAudioType(index,false,false)
  })
  //音頻進度播放更新
  that.data.audio.onTimeUpdate(function () {
   //設置總時長
   if(arr[index].totalProcess == '00:00' || arr[index].totalProcessNum == '00:00'){
    that.setTotal(index,that.time_to_sec(that.data.audio.duration), that.data.audio.duration)
   }
   //沒有觸動滑動事件更新進度
   if(!arr[index].isMove){
    that.setCurrent(index,that.time_to_sec(that.data.audio.currentTime), that.data.audio.currentTime)
   }
  })
 },
 //開始滑動觸發(fā)
 start : function (e) {
  let arr = this.data.cc
  let index = e.currentTarget.dataset.index
  this.move(index,true)
 },
 //觸發(fā)滑動條
 changeSlide : function (e) {
  let that = this
  let arr = that.data.cc
  let index = e.currentTarget.dataset.index
  const position = e.detail.value
  let seek = arr[index].seek
  seek = position
  if (seek != -1) {
   wx.seekBackgroundAudio({
    position: Math.floor(position),
   })
   seek = -1
  }
  that.setCurrent(index,that.time_to_sec(position), position)
  that.seek(index,seek)
 },
 //結(jié)束滑動觸發(fā)
 end : function (e) {
  let arr = this.data.cc
  let index = e.currentTarget.dataset.index
  this.move(index, false)
 },
 //停止播放音頻
 pauseAudio:function (e) {
  let that = this
  let index = e.currentTarget.dataset.index
  that.data.audio.pause()
  that.setAudioType(index,false,true)
 },
 //設置音頻圖片狀態(tài)以及滾動條可播放狀態(tài)函數(shù)
 setAudioType: function (index, tag, tagSlide, ) {
  let that = this
  let arrs = that.data.cc
  arrs[index].showAudio = tag
  arrs[index].canSlider = tagSlide
  that.setData({
   cc:arrs
  })
 },
 //設置音頻當前播放時間以及滾動條當前位置函數(shù)
 setCurrent: function (index,currentProcess, currentProcessNum) {
  let that = this
  let arrs = that.data.cc
  arrs[index].currentProcess = currentProcess
  arrs[index].currentProcessNum = currentProcessNum
  that.setData({
   cc: arrs
  })
 },
 //設置音頻總播放時間以及滾動條總位置函數(shù)
 setTotal: function (index,totalProcess, totalProcessNum) {
  let that = this
  let arrs = that.data.cc
  arrs[index].totalProcess = totalProcess
  arrs[index].totalProcessNum = totalProcessNum
  that.setData({
   cc: arrs
  })
 },
 //設置滾動條是否滾動狀態(tài)函數(shù)
 move:function (index,isMove) {
  let that = this
  let arrs = that.data.cc
  arrs[index].isMove = isMove
  that.setData({
   cc: arrs
  })
 },
 //設置音頻時間點函數(shù)
 seek: function (index, seek) {
  let that = this
  let arrs = that.data.cc
  arrs[index].seek = seek
  that.setData({
   cc: arrs
  })
 },

總結(jié)

以上所述是小編給大家介紹的微信小程序多音頻播放進度條問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對創(chuàng)新互聯(lián)網(wǎng)站的支持!

網(wǎng)頁標題:微信小程序多音頻播放進度條問題
當前地址:http://aaarwkj.com/article48/ipcohp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供面包屑導航、網(wǎng)站營銷、定制網(wǎng)站標簽優(yōu)化、、自適應網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設計
91精品麻豆国产自产在线| 伊人色综合久久天天五月婷| 国产又猛又黄又爽无遮挡| 欧美日韩另类综合91| 超碰97免费在线观看| 亚洲精品区免费观看av| 亚洲av天堂在线观看| 麻豆午夜视频免费在线观看| 亚洲国产黄片在线播放| 国产亚洲精品久久久闺蜜| 国产国产成年年人免费看片| 亚洲婷婷综合精品五月天| 黑人巨大精品欧美久久| 曰本真人性做爰视频免费| 国产成人亚洲精品乱码| 国产精品国产不卡在线| 国欧美一区二区三区| 欧美精品日本一区二区| 视频二区国产欧美日韩| 国产中文字二暮区2021综合| 国产激情在线四五区观看| 极品大胸美女被啪啪的高潮| 欧美欧美欧美欧美一二三区| 夜夜高潮夜夜爽免费观看| 说中文字幕的黄色大网站| 日本久久在线观看视频| 91麻豆国产福利在线| 男人午夜影视在线观看| 国产精品三级玖玖玖电影| 久国产精品韩国三级视频| 乱色熟女一区二区三区| 日本av在线中文一区二区| 日韩高清不卡免费视频| 欧美日韩视频在线第一页| 女人被爽到高潮呻吟免费看| 亚洲av日韩专区在线观看| 人人妻人人澡人人揉| 视频免费观看网站不卡| 亚洲国产精品高清久久| 一区二区三区四区四虎| 日本一区二区三区视频版|