【问题标题】:Load and Play playlist.m3u8 to START at a specific time on an iPad?在 iPad 上的特定时间加载和播放 playlist.m3u8 以开始?
【发布时间】:2025-12-18 09:25:02
【问题描述】:

我在 FF/IE 上运行了这段代码,但是在 iPad 上时监听器被忽略了。我从“canplay”事件开始,但在 [here][1] 找到了 loadmetadata 事件。不知道如何告诉 ipad 去起点 - 有什么建议吗?

<video id='video' controls preload='none' >
    <p>Your user agent does not support the HTML5 Video element.</p>
</video>

// For firefox and develpent
var src = 'http://media.w3.org/2010/05/video/movie_300.webm';
// For actual IPad production environment using our Wowza media server
var src = 'http://www.ourwowzaserver/videos/mp4:ourvideo.mp4/playlist.m3u8';

var start_seconds = 45;

document._video = document.getElementById("video");
document._video.setAttribute("src", src);
document._video.play();
document._video.addEventListener('loadedmetadata', function() {
        this.currentTime = start_seconds;
    }, false);


[1]: http://*.com/questions/5981427/start-html5-video-at-a-particular-position-when-loading  

【问题讨论】:

  • 这段代码是在视频对象创建后执行的吗?
  • 是的。刚刚编辑问题以显示它
  • 好吧,我可以告诉你一个问题……你正试图在 Safari 上播放 webm 视频。 Safari 不播放该类型的视频。见这里:w3schools.com/html/html5_video.asp
  • @user1470118 - 这只是问题...我使用 FF/webm 进行修补/开发,然后在 ipad 上使用 mp44/m3u8。一切都在实际代码中加载/播放,除了设置当前时间。

标签: javascript html ipad html5-video


【解决方案1】:

您是否尝试过使用 DOM 事件?

document._video.onloadedmetadata=document._video.currentTime = start_seconds;

http://www.w3schools.com/tags/av_event_loadedmetadata.asp

【讨论】: