html52.com
我爱小程序-开发者交流社区

iOS 音频播放要加载6-7秒,安卓没问题

问题模块 框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
API和组件 小程序 Bug wx.createInnerAudioContext() 客户端 iOS 6.71 1.90

使用的是阿里云oss存储的音频。格式为mp3。

点击开始播放需要加载好几秒,切换别的语音,再点之前播放过得,也要重新加载好久,就算是几秒的语音也要加载好久



以下为语音:

<!--  语音  -->
            <view class="row-module-audio" wx:if="{{item.SpeechType == 1}}">
                <view class="audio-item detail-direction {{audioplaying == index && !audioplay ? 'audio-item-loading' : ''}}" data-src="{{item.ModuleContent.Url}}" data-index="{{index}}" bindtap='audioPlay' style="width:{{item.ModuleContent.Seconds != 0 && item.ModuleContent.Seconds != null ? item.ModuleContent.width : ''}};">         
                    <view class="audio-state {{audioplaying == index && audioplay ? 'audio-item-playing' : ''}}"></view>
                    <text>{{item.ModuleContent.Seconds != 0 && item.ModuleContent.Seconds != null ? item.ModuleContent.size : '00:00/00:00'}}</text>
                </view>
            </view>

以下为播放JS:

audioPlay: function(e) {
        var that = this
        var src = e.currentTarget.dataset.src
        var index = e.currentTarget.dataset.index
        var audioplaying = this.data.audioplaying
        var videoPlaying = this.data.videoPlaying
        //如果有正在播放的音频且不是当前点击的音频,暂停播放该音频。是当前点击的,则停止播放音频
        if (audioplaying != null){
            if (audioplaying != index) {
                clearInterval(that.playTimer)
                that.setItemData(audioplaying)
                audioplaying = index
                audio.src = src
                audio.play()
            } else {
                audioplaying = null
                audio.stop()
                clearInterval(that.playTimer)
                that.setItemData(index)
            }
        } else {
            audioplaying = index
            audio.src = src
            audio.play()
        }
        //如果有正在播放额视频,暂停播放该视频
        if (videoPlaying != null){
            var videoContextPrev = wx.createVideoContext('video_' + videoPlaying)
            videoContextPrev.pause()
        }
         
        this.setData({
            audioplaying: audioplaying,
            audioplay: false,
            videoPlaying: null
        })
    }



求助。问题直接和体验挂钩。

网友回复

娇华:

你好,麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

酱汁:

有人吗

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付