Mentre questa domanda è piuttosto vecchia, il problema rimane aperto. Ho scoperto una soluzione che funziona su iPad testati multipli (1 + 2 + 3) per iOS 5 e 6 (iOS3 + 4 non testato):
Fondamentalmente devi prima attendere l'evento playing
iniziale, quindi aggiungerne uno -time binder per canplaythrough
e quindi per progress
- solo in questo modo è possibile modificare il valore currentTime
. Qualsiasi tentativo prima fallirà!
Il video deve iniziare la riproduzione all'inizio, il che rende un livello nero sopra l'elemento video molto utile. Purtroppo, i suoni all'interno del video non può essere disattivato tramite JavaScript -> non un UX perfetta
// 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();
}
});
}
il tutto può essere scaricato dal my GitHub repo
fonte
2012-12-11 19:06:30
già provato: - \. Niente da fare. – K2xL