Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

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);
}

1 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi, there.

It looks like you’re serving up a HLS stream (M3U8) and falling back to a MOV file. There seems to be a few issues with your current setup:

1. The HLS stream is not able to be played on any browser or device because there are CORS/Crossdomain issues. Your Cloudfront host has to have CORS/Crossdomain set up to allow *.mydiveo.com access. Please see our support article on Crossdomain File Loading for more information on how to rectify this.

2. While our player technically supports Quicktime’s video format (MOV), some browsers and devices do not. And even when they do, playback may be not as good as you would like it to be. We recommend re-encoding your video file as a MP4 using the H.264 codec for video and AAC for audio. You can use a program like Handbrake (http://www.handbrake.fr – free) for this.

3. It seems like your setup code has a lot of legacy items in there that have either changed, or are no longer needed. For example, our player no longer uses the modes or smoothing configuration options, so you can take that out.

Also, primary: “html5” is not necessarily needed, because our player will always prefer HTML5 over Flash, unless you set primary: “flash”. Especially in the case of HLS, you’d want to leave that off because our player uses Flash Player to play HLS content in browsers that do not natively support it (Chrome, Firefox, IE).

In addition, androidhls: true used to be required to enable HLS playback on Android, but it is no longer needed as of version 7.0.1.

To answer your original question, the reason that you are having issues with playback on Android devices is because of the CORS/Crossdomain issues with your HLS stream plus it cannot fall back to the second source because Chrome for Android does not support MOV files. If you fix your Crossdomain related issues and reencode your secondary source as MP4, you should be able to play either source on Chrome for Android.

I hope this helps! Please let me know if you need any more help or have any other questions.

Thank you!

This question has received the maximum number of answers.