视频路径为https://yhp.pg024.com/Upload/video/3974E3A4021644F9234C2B04F911D3C9.mp4
<template>
<view>
<video class="videoPart" :src="src" controls loop :show-fullscreen-btn="false"
:id="`video_${src}`" ref="`video_${src}`" @timeupdate="timeupdate">
</video>
</view>
</template>
<script>
export default{
props:{
src:{
type:String,
default:''
},
play:{
type:Boolean,
default:false
},
initialTime:{
type:Number,
default:0
},
},
data(){
return{
time:0,
duration:0,
playFirst:true
}
},
mounted() {
this.videoCtx = uni.createVideoContext(`video_${this.src}`,this)
},
methods:{
timeupdate(event){
this.duration = event.detail.duration
if(!this.play) return
if(this.time>=this.duration) this.time=0
this.time = event.detail.currentTime
},
videoPlay(){
if(this.play){
this.videoCtx.play();
if(this.playFirst){
this.videoCtx.seek(this.startTime)
this.playFirst = false
}
}else{
this.videoCtx.pause();
this.$emit('pause',this.time)
}
},
},
watch:{
play(newVal,oldVal){
this.videoPlay()
},
startTime:{
immediate: true,
handler(newVal,oldVal){
this.time = newVal
}
},
},
computed:{
startTime(){
return this.initialTime
}
}
}
</script>
<style scoped>
.videoPart{width: 100%;height: auto;max-height: 100%;position: static;}
</style>
小程序视频在ios端无法播放,时间都是00:00,点击没效果
问题解决了吗?亲,我也碰到一样的问题
你好,建议加上binderror排查下是否有报错信息提示