由于uni-app的 video 标签已经被框架重置了,所以不支持里面添加source和track标签,故无法直接添加多种视频源和字幕,
下面是通过iframe的解决方案:
一、在最外层的static目录里添加常规 index.html页面,宽高设置为100%
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
*{padding:0; margin:0;}
html,body{width:100%; height:100%;}
.video-box{width:100%; height:100%;}
</style>
</head>
<body>
<video class="video-box" x5-playsinline="" playsinline="" webkit-playsinline="" controls>
<source size="480" src="./video_480p.mp4" type="video/mp4" />
<source size="720" src="./video_720p.mp4" type="video/mp4" />
<track default kind="captions" label="" src="./zimu.vtt" srclang="en" />
</video>
</body>
</html>
二、通过用标签引入该常规的html页面,设定宽高
<iframe src="./static/html/video.html" frameborder="0" width="100%" height="100%"></iframe>
经测试,这方法最值得欣慰的是点击全屏播放不会受到iframe的限制,所以可以放心使用(当然,如果是PC网页的话,也要注意兼容性)