Question

I know this question has been asked many times here, but I could not come to a standard solution from them. So need help.

I simply need to show my .mp4 videos in jwplayer 5.10, such that it will show in flash version where it gets flash otherwise in html5 version.

Here's my code :

jwplayer("video_holder").setup({
    'height': '300',
    'width': '100%',
     modes: [
       { type: "flash",
         src: "player.swf",
         config: {
              file: "http://example.com/path/to/video.mp4",
         }
       },
       { type: "html5",
         config: {
              file: "http://example.com/path/to/video.mp4"
         }
       }
     ]
});

FYI : I am converting all my videos in .mp4 format, using ffmpeg, libx264 It does not load the video in Chrome and IOS, works with flash in FF.

What am I doing wrong here?

Was it helpful?

Solution

You're making it much more complicated than it really is. Here's a simple demo page that does what you want.

http://misterneutron.com/JW5video/

And here's the page code:

<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>JW5</title>
<script type='text/javascript' src='jwplayer.js'></script>
</head>
<body>
<div id='myElement'>Loading the player...</div>
<script type='text/javascript'>
    jwplayer('myElement').setup({
        flashplayer: 'player.swf',
        file: 'wildlife.mp4',
        image: 'wildlife.jpg',
        width: 640,
        height: 360
    });
</script>
</body>
</html>

OTHER TIPS

Yep, it plays fine with the jwplayer configuration made by MisterNeutron. It seems the problem was for some reason, the player was not able to access the videos in my local machine (may be some problem with permission, will investigate later). However it played fine in my DEV server.

In case someone stumbles upon this post and want a better explanation:

I am converting all user uploaded videos to mp4 extension to be played by jwplayer in flash version and html5 video on fallback. The ffmpeg video conversion script is like follows:

ffmpeg -y -i 'input_file' -c:v libx264 -crf 23 -profile:v baseline -c:a aac -strict experimental 'output_file'

Hope this helps somebody and thanks a lot for your help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top