在我的iPhone上,我尝试了以下HTML和JavaScript:
<video id="myvideo" src="" width="352" height="288" autoplay></video>
<script>
var vdo = document.getElementById('myvideo');
vdo.src = 'http://server-address:9902/208AC328657F5332-live-1.m3u8';
vdo.play();
</script>
但视频元素在我点播之前没有开始播放。为什么呢?
谢谢,任何帮助将不胜感激!
答案 0 :(得分:4)
iPhone上会忽略自动播放属性。这只是他们在实现过程中做出的决定,就像他们使用控件一样(无论什么都显示出来。)
答案 1 :(得分:2)
您需要先加载视频...
<video id="myvideo" src="" width="352" height="288" autoplay></video>
<script>
var vdo = document.getElementById('myvideo');
vdo.src = 'http://server-address:9902/208AC328657F5332-live-1.m3u8';
vdo.load(); // video must be loaded
vdo.play(); // after success load it can be played
</script>
答案 2 :(得分:0)
您是否真的将JavaScript放在HTML中,直接放在视频标记之后?
我不确定它是否会起作用,但您需要在<script>
标记中使用JavaScript才能将其解释为JavaScript:
<video id="myvideo" src="" width="352" height="288" autoplay></video>
<script>
var vdo = document.getElementById('myvideo');
vdo.src = 'http://server-address:9902/208AC328657F5332-live-1.m3u8';
vdo.play();
</script>