
Video won't play on Android
Hello everyone,
My jw player setup is playing well on everything except Android.
I was having trouble with the player playing the fallback method automatically, so I added in
my own error checking and it seems to be working.
When I look at the console on my android, it shows that the fallback method is being activated, the video plays for about 6 seconds and then just shows loading forever.
My code is below, and a live url is: http://goo.gl/ODI9Ce
Any advice would be greatly appreciated!
jQuery(document).ready(function(){
window.fallback_enabled = false;
window.player_options = {
'width': '100%', // jw player options
playlist: [{
image: "<?php echo $video_thumbnail; ?>",
sources: [{
file: '<?php echo $video_url; ?>' // hls as default playback format
},{
file: '<?php echo $fallback_video_url; ?>' // fallback playback format
}]
}],
'smoothing':'true',
"aspectratio": "16:9",
"androidhls": "true",
'autostart': 'true',
'primary': 'html5',
'modes': [
{ type: 'html5' },
{ type: 'flash', src: '<?php echo $this->base;?>/js/jwplayer.flash.swf' }
]
}
window.player = jwplayer('mediaplayer').setup(window.player_options); // setup jw player
if (window.player.getState() !== 'buffering' || window.player.getState() !== 'playing'){
window.player.play(true);
}
function playFallback(){
if(window.fallback_enabled == false){
window.fallback_enabled = true; // prevent this from happeneing more than once
window.player.load([{file:"<?php echo $fallback_video_url; ?>"}]); // load the fallback video
window.player.play(true); // play the video - needed for mobile
//console.log('fallback format is being used');
}
}
/*
player.on('bufferChange', function(){
console.log(player.getBuffer());
});
*/
window.player.on('error', playFallback()); // on error, try the fallback method
window.player.on('setupError', playFallback()); // on setup error, try the fallback method
//console.log('primary: <?php echo $video_url; ?>');
//console.log('fallback: <?php echo $fallback_video_url; ?>');
});
var initSound = function() {
window.player.load();
window.player.play(true);
document.removeEventListener('touchstart', initSound, true);
}