当前位置:网站首页>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 .
边栏推荐
- Basic knowledge of binary tree, BFC, DFS
- Path of class file generated by idea compiling JSP page
- Practical development of member management applet 06 introduction to life cycle function and user-defined method
- . Net interprocess communication
- 10 exemples les plus courants de gestion du trafic istio, que savez - vous?
- Data processing methods - smote series and adasyn
- P2648 make money
- Global and Chinese markets for endoscopic drying storage cabinets 2022-2028: Research Report on technology, participants, trends, market size and share
- VNCTF2022 WriteUp
- Mysql数据库慢sql抓取与分析
猜你喜欢
1291_Xshell日志中增加时间戳的功能
In depth MySQL transactions, stored procedures and triggers
MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0
【leetcode】1189. Maximum number of "balloons"
Solution to the problem that the root account of MySQL database cannot be logged in remotely
Overturn your cognition? The nature of get and post requests
Data processing methods - smote series and adasyn
Mysql database storage engine
One question per day (Mathematics)
[adjustable delay network] development of FPGA based adjustable delay network system Verilog
随机推荐
CertBot 更新证书失败解决
Global and Chinese markets for medical gas manifolds 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of rubber wheel wedges 2022-2028: Research Report on technology, participants, trends, market size and share
Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
Recommendation | recommendation of 9 psychotherapy books
Viewing and verifying backup sets using dmrman
About some basic DP -- those things about coins (the basic introduction of DP)
Basic knowledge of binary tree, BFC, DFS
math_ Derivative function derivation of limit & differential & derivative & derivative / logarithmic function (derivative definition limit method) / derivative formula derivation of exponential functi
VPP performance test
Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
IDEA编译JSP页面生成的class文件路径
【leetcode】1189. Maximum number of "balloons"
How can programmers resist the "three poisons" of "greed, anger and ignorance"?
2327. Number of people who know secrets (recursive)
软考 系统架构设计师 简明教程 | 总目录
C. The third problem
729. My schedule I (set or dynamic open point segment tree)
Mysql database storage engine