この質問はかなり古いものですが、問題は未解決のままです。iOS 5 および 6 (iOS3+4 はテストされていません) 用の複数のテスト済み iPad (1+2+3) で動作するソリューションを発見しました。
基本的に、最初のイベントを待つ必要があります。次にplaying
、1 回限りのバインダーを追加してから、実際に値を変更する必要があります。それより前の試行はすべて失敗します。canplaythrough
progress
currentTime
ビデオは最初に再生を開始する必要があります。これにより、ビデオ要素の上に黒いレイヤーが少し便利になります。残念ながら、ビデオ内のサウンドは JavaScript を介して無効にすることはできません --> 完璧な UX ではありません
// https://github.com/JoernBerkefeld/iOSvideoSeekOnLoad / MIT License
// requires jQuery 1.8+
// seekToInitially (float) : video-time in seconds
function loadingSeek(seekToInitially, callback) {
if("undefined"==typeof callback) {
callback = function() {};
}
var video = $("video"),
video0 = video[0],
isiOS = navigator.userAgent.match(/(iPad|iPhone|iPod)/) !== null,
test;
if(isiOS) { // get the iOS Version
test =navigator.userAgent.match("OS ([0-9]{1})_([0-9]{1})");
// you could add a loading spinner and a black layer onPlay HERE to hide the video as it starts at 0:00 before seeking
// don't add it before or ppl will not click on the play button, thinking the player still needs to load
}
video.one("playing",function() {
if(seekToInitially > 0) {
//log("seekToInitially: "+seekToInitially);
if(isiOS) {
// iOS devices fire an error if currentTime is set before the video started playing
// this will only set the time on the first timeupdate after canplaythrough... everything else fails
video.one("canplaythrough",function() {
video.one("progress",function() {
video0.currentTime = seekToInitially;
video.one("seeked",function() {
// hide the loading spinner and the black layer HERE if you added one before
// optionally execute a callback function once seeking is done
callback();
});
});
});
} else {
// seek directly after play was executed for all other devices
video0.currentTime = seekToInitially;
// optionally execute a callback function once seeking is done
callback();
}
} else {
// seek not necessary
// optionally execute a callback function once seeking is done
callback();
}
});
}
全体は私の GitHub リポジトリからダウンロードできます