ad *_*ees 10 javascript mobile-safari html5-video cordova
我正在尝试将一些事件附加到我的iPad网络应用程序中的HTML5视频元素,但它们似乎没有被解雇?我已经在设备和模拟器中对此进行了测试,并得到了相同的结果.然而事件(至少onclick)在桌面Safari中工作正常.我也尝试过交换div的视频元素,事件发生了吗?有没有其他人遇到这个并有想法解决问题?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test video swipe</title>
</head>
<body>
<video src='somevid.mp4' id='currentlyPlaying' width='984' height='628' style='background-color:#000;' controls='controls'></video>
<script>
var theVid = document.getElementById("currentlyPlaying");
theVid.addEventListener('touchstart', function(e){
e.preventDefault();
console.log("touchstart");
}, false);
theVid.addEventListener('click', function(e){
e.preventDefault();
console.log("click");
}, false);
theVid.addEventListener('touchmove', function(e){
console.log("touchmove");
}, false);
theVid.addEventListener('touchend', function(e){
console.log("touchend");
}, false);
theVid.addEventListener('touchcancel', function(e){
console.log("touchcancel");
}, false);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
根据我过去几周的痛苦经历,我可以开始这样的清单(至少对于iPad 3.2).其中一些"特征"可能会被记录,但相关的句子通常很难找到.
volume属性被忽略(您可以设置它,它似乎会改变,但设备上的实际音量不会受到影响).currentTime物业是只读的.我的解决方法是调用load(),这至少允许我重置到剪辑的开头.onended事件将不会发布可靠的,除非控件是可见的.我对这个解决方法是监控timeupdate事件和比较currentTime的durationautobuffer并被autoplay禁用.<video>标签时,许多css规则似乎没有按预期运行- 例如.opacity并且z-index两者似乎都无效,这意味着你无法调暗或隐藏视频.你可以设置display:none,但这是非常突然的.正如我所说,这可能不是一个详尽的清单,我欢迎补充或更正.
(此外,经过大量的谷歌搜索,我在这里找到了一个列表,其中包含移动Safari支持的QT插件方法和属性的微薄子集).