当前位置: 首页 > ai >正文

uniapp 处理app video组件各种问题

解决思路

要做短视频小程序并且在  小程序 app通用 哎~

1. 在app端 用h5原生video

<view v-html="'<video src=''><video/>'"></view>

2.控制使用renderjs

renderjs文档

// 绑定数据 向视图层传递
<view class="" :currentSwiperIndex="currentSwiperIndex" :change:currentSwiperIndex='videoMod.videoManage'></view>
// 触发视图层方法
<view @click.stop="videoMod.showControls" :currentSwiperIndex="currentSwiperIndex" ></view>
<script module="videoMod" lang="renderjs">export default {data() {return {currentSwiperIndex: 0,lastSwiperIndex: 0}},mounted() {},methods: { setCurrentTime(event, ownerInstance){let video = document.getElementById(`video_${this.currentSwiperIndex}`); var duration = video.duration;  let updateCurrentTime =   duration * ( event.target.value / 100  );  video.currentTime = updateCurrentTime; },showControls(event, ownerInstance) { let video = document.getElementById(`video_${this.currentSwiperIndex}`); let type = video.paused ? 'play' : 'pause';video[type]();//向逻辑层通信并且传递数据ownerInstance.callMethod('onVideoType', type);}, videoManage(newValue, oldValue, ownerVm, vm) {  this.currentSwiperIndex = newValue;this.lastSwiperIndex = oldValue;if (newValue < 0) return;let video = document.getElementById(`video_${this.currentSwiperIndex}`);if (!video) return;video.play();let timeupdate = ()=>{var currentTime = video.currentTime; // 获取当前播放时间(秒)var duration = video.duration; // 获取视频总时长(秒)var percent = (currentTime / duration) * 100; // 计算播放进度百分比 //向逻辑层通信并且传递数据ownerVm.callMethod("synchronous",{percent:percent.toFixed(2),id:newValue,currentTime,duration, }) }// video.addEventListener('timeupdate', timeupdate);let oldValueVideo = document.getElementById(`video_${this.lastSwiperIndex}`);if (!oldValueVideo) return;oldValueVideo.pause(); // oldValueVideo.removeEventListener("timeupdate",timeupdate);},}}
</script>

一点都不卡 收工

http://www.xdnf.cn/news/1293.html

相关文章:

  • vue+flask+lstm高校舆情分析系统 | 可获取最新数据!
  • 蓝桥杯17. 机器人塔
  • gem5-gpu教程04 高速缓存一致性协议和缓存拓扑
  • 服务器配置环境-condapytorch_20250422
  • Java从入门到“放弃”(精通)之旅——String类⑩
  • C#多线程访问资源
  • Node.js 开发用户登录功能(使用mysql实现)
  • 【AI应用】免费代码仓构建定制版本的ComfyUI应用镜像
  • 【Linux应用】RADXA ZERO 3快速上手:镜像烧录、串口shell、外设挂载、WiFi配置、SSH连接、文件交互
  • Zookeeper是什么?基于zookeeper实现分布式锁
  • 软件黑盒与白盒测试详解
  • 同样的接口用postman/apifox能跑通,用jmeter跑就报错500
  • 【MCP】第二篇:IDE革命——用MCP构建下一代智能工具链
  • 【Linux】冯诺依曼体系结构及操作系统架构图的具体剖析
  • 【Ubuntu】关于系统分区、挂载点、安装位置的一些基本信息
  • 【算法笔记】动态规划基础(一):dp思想、基础线性dp
  • 【k8s】docker、k8s、虚拟机的区别以及使用场景
  • sentinel
  • CATBOOST算法总结
  • vscode如何多行同时编辑,vscode快速选中多行快捷键
  • 使用 JUnit 4在 Spring 中进行单元测试的完整步骤
  • 【数据结构入门训练DAY-21】信息学奥赛一本通T1334-围圈报数
  • 深入剖析TCP协议(内容二):从OSI与TCP/IP网络模型到三次握手、四次挥手、状态管理、性能优化及Linux内核源码实现的全面技术指南
  • 基于cubeMX的hal库STM32实现MQ2烟雾浓度检测
  • 软考软件设计师30天备考指南
  • 升级xcode16之后react-native-zip-archive不兼容,unsupported option ‘-G‘
  • The backpropagation and the brain
  • Java与C语言核心差异:从指针到内存管理的全面剖析
  • Node.js学习
  • WT2000T专业录音芯片:破解普通录音设备信息留存、合规安全与远程协作三大难题