uniapp APP端解决video seek跳转时间不准确的问题

	<video id="myVideo" ref="myVideo"
				poster="/static/images/videoPoster.png" 
				@timeupdate="timeupdate"
				:duration="duration"
				:current="currentTime"
				:src="localVideoPath"
				:advanced="advanced"
				object-fit="fill" 
				controls="true" 
				show-play-btn="true" 
				show-center-play-btn="true" 
				show-loading="true">
    </video>

 设置advanced

data() {
	return {
        //seek生效的关键代码
		advanced: [  
			{
				 "key": "enable-accurate-seek",  
				 "value": 1,  
				 "type": "player",  
			}
		]				
		currentTime: 0,
		videoUrl: '',
		localVideoPath: '',
	}
}

onload  方法

需要设置好video的src路径后再创建 uni.createVideoContext

 onLoad(e){
    //这里是先下载到本地,然后再播放的
	let localVideoPath = uni.getStorageSync(this.videoUrl);
    //网络地址可以正常跳转但是本地地址不行,设置之后就正常了
	this.localVideoPath = plus.io.convertLocalFileSystemURL(localVideoPath)
	this.$nextTick(() => {
		this.videoContext = uni.createVideoContext('myVideo',this)
		this.videoHeight = 450;
	})
	this.$forceUpdate()
},

seek 需要整型 

seek(time) {
	let currentTime = parseInt(time);
	this.currentTime = currentTime;
	this.videoContext.seek(currentTime);
	console.info("seek",currentTime)
	setTimeout(() => {
		this.videoContext.play();
	}, 200);
}

参考:video 组件 高阶晋级

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 10:02:03       53 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 10:02:03       56 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 10:02:03       46 阅读
  4. Python语言-面向对象

    2024-07-11 10:02:03       57 阅读

热门阅读

  1. 系统架构设计师——数据模型

    2024-07-11 10:02:03       22 阅读
  2. AEC10 SA计算整理 --- ExtremeColorSA & SaliencySA

    2024-07-11 10:02:03       18 阅读
  3. 探索 Postman API 网络图:可视化 API 交互的窗口

    2024-07-11 10:02:03       21 阅读
  4. (131)EMIF接口--->(003)基于FPGA实现EMIF接口

    2024-07-11 10:02:03       20 阅读
  5. 分析一下多方联合计算中的数据泄露场景

    2024-07-11 10:02:03       17 阅读
  6. VSCode,请打开文件始终在新标签页打开

    2024-07-11 10:02:03       19 阅读
  7. JIRA的高级搜索JIRA Query Language(JQL)详解

    2024-07-11 10:02:03       24 阅读
  8. 开源项目有哪些机遇与挑战?

    2024-07-11 10:02:03       18 阅读
  9. 多器官功能障碍综合征

    2024-07-11 10:02:03       19 阅读
  10. ABAP中预制会计凭证的BAPI使用方法

    2024-07-11 10:02:03       18 阅读