uniapp 开发的小程序
代码片段
https://developers.weixin.qq.com/s/PG4DNKm67CQZ
播放
created() {
this.innerAudioContext = uni.createVideoContext("videoPlayer", this);
},
mounted() {
this.innerAudioContext.src = 'https://xxxxxxxxxxx.mp3'
},
methods: {
audioPlay() {
this.innerAudioContext.play() // ios真机无反应,别的都可以
this.isPlaying = true
}
}
目前项目里手动播放视频是没问题的,你按楼上的方法试试看
var playPromise = this.innerAudioContext.play() if ( playPromise !== undefined ) { playPromise.then( res => { // Autoplay started } ).catch( error => { console.log( "===播放被拦截===", error ) this.isPlaying = false}
打印下播放错误信息,视频应该是没加载完成