Issue summary: I'm trying to play a sequence of youtube videos using the youtube iFrame api on iPhone (Only tested IOS8). I play the first loaded video by pressing the youtube play button, when i get the ended state i load the next video using loadVideoById. It works flawless for the first 4 videos but then the player get stuck in state 3 buffering and nothing happens. I have tried different youtube ids and and also using the same youtube id over and over again, but it allways get stuck on the fifth video.
Here is the code:
<script>
var tag = document.createElement('script');
tag.src = "http://ift.tt/18NYSmg";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
var videos = ["fWIBXhQrHE4", "hMo2ovaa8bc", "sOpuSRj7IN4", "fWIBXhQrHE4", "hMo2ovaa8bc", "sOpuSRj7IN4", "fWIBXhQrHE4", "hMo2ovaa8bc", "sOpuSRj7IN4", "fWIBXhQrHE4", "hMo2ovaa8bc", "sOpuSRj7IN4"];
var currentVideo = 0;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: videos[currentVideo],
playerVars: {
disablekb: 0
},
events: {
'onReady': onPlayerReady,
'onStateChange': onStateChange
}
});
}
function onStateChange(event) {
console.log("state: " + event.data);
switch(event.data){
case YT.PlayerState.ENDED:
loadNext();
break;
}
}
function loadNext() {
if(currentVideo < videos.length-1){
currentVideo++;
console.log("currentVideo: " + currentVideo);
player.loadVideoById(videos[currentVideo], 0, "hd720");
}
else{
console.log("ALL DONE");
}
}
function onPlayerReady(event) {
//console.log("playerready");
//event.target.playVideo();
}
</script>
Steps to reproduce issue:
Run this fiddle http://ift.tt/1HL0iTD or the attached code in safari on an iPhone with IOS 8.
Press play on the youtube player.
- When the video started in fullscreen press the next button to trigger the ended event, the player exits fullscreen loads the next video and opens fullscreen again.
- Redo step 3 four times and the player get stuck in state 3 buffering.
Expected output: The player should play the loaded video.
Actual results: The player get stuck in state 3 buffering.
I also found this threads about the issue and wonder if anyone solved it? http://ift.tt/19y9vJo
Aucun commentaire:
Enregistrer un commentaire