当前位置:网站首页>How to realize automatic playback of H5 video
How to realize automatic playback of H5 video
2022-07-06 04:19:00 【echozly】
State in advance , This article is only for <video> label .
Now in the project, we often encounter in H5 Embedded video in the page , Sometimes you have to play it automatically , I didn't think it was a difficult point before , But in practice, it's a chicken feather . I found various strategies on the Internet , After stepping on various pits , Several points are summarized , I hope I can give you a reference .
I won't say more about various methods of stepping on pits , Just say that the actual measurement is effective , So as not to delay everyone's time
First of all PC End ,PC The end is relatively easy , The browser to <video> The compatibility of labels is still very good , First you need to set autoplay by true
But if you only set autoplay Is unable to achieve the effect of automatic playback , You also need to set muted by true, Mute playback
In this way, simple automatic video playback can be realized .
The second is mobile terminal , Automatic video playback is forbidden on the mobile terminal , To avoid wasting user traffic . Therefore, the mobile terminal needs an interactive event to control video playback .
First create and return video Context videoContext object , has uni For example :
this.videoContext = uni.createVideoContext('myVideo');
Then the monitoring event triggers
this.videoContext.play();
It is worth noting that ,touch Touching related events cannot control video playback , Only tap and click Events can , It's just that , If you can't realize it directly, you can only detour .
Although the above content is very simple , But there is no need to step on the pit , Real machine measurement , If you want to pass only <video> Tag to realize automatic playback , At least the information I searched cannot be perfectly realized , If there is a better way , I hope you can give me some advice .
边栏推荐
- Execution order of scripts bound to game objects
- Lombok principle and the pit of ⽤ @data and @builder at the same time
- 【HBZ分享】ArrayList的增删慢查询快的原因
- Class A, B, C networks and subnet masks in IPv4
- Path of class file generated by idea compiling JSP page
- How many of the 10 most common examples of istio traffic management do you know?
- PTA tiantisai l1-078 teacher Ji's return (15 points) detailed explanation
- 关于进程、线程、协程、同步、异步、阻塞、非阻塞、并发、并行、串行的理解
- P3500 [POI2010]TES-Intelligence Test(二分&离线)
- Tips for using dm8huge table
猜你喜欢
记一次excel XXE漏洞
Stable Huawei micro certification, stable Huawei cloud database service practice
Mysql数据库慢sql抓取与分析
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
Data processing methods - smote series and adasyn
Benefits of automated testing
Stack and queue
[Zhao Yuqiang] deploy kubernetes cluster with binary package
解决“C2001:常量中有换行符“编译问题
Lora gateway Ethernet transmission
随机推荐
【HBZ分享】ArrayList的增删慢查询快的原因
满足多元需求:捷码打造3大一站式开发套餐,助力高效开发
Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
Data processing methods - smote series and adasyn
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
Solution to the problem that the root account of MySQL database cannot be logged in remotely
1008 circular right shift of array elements (20 points)
Slow SQL fetching and analysis of MySQL database
Tips for using dm8huge table
Easyrecovery靠谱不收费的数据恢复电脑软件
P2022 interesting numbers (binary & digit DP)
[FPGA tutorial case 11] design and implementation of divider based on vivado core
颠覆你的认知?get和post请求的本质
[PSO] Based on PSO particle swarm optimization, matlab simulation of the calculation of the lowest transportation cost of goods at material points, including transportation costs, agent conversion cos
HotSpot VM
解决“C2001:常量中有换行符“编译问题
Fundamentals of SQL database operation
The value of two date types is subtracted and converted to seconds
[Zhao Yuqiang] deploy kubernetes cluster with binary package
tengine 内核参数