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

Insert primary:flash Into All Video Players Site-Wide


Hello,

I'm working on a site with 500+ videos that have already been embedded using JW Player. They use the cloud player (just recently upgraded from JW6 to JW7) so the script exists in the <head> of the site and the individual players are embedded across 500+ individual pages. We just discovered that a lot of the videos will intermittently have "glitches" when being played in the Firefox browser. Sometimes the audio or video (or both) will drop out, sometimes the files are slow to load, sometimes they start and stop frequently, etc., and sometimes they play normally.

The videos are all .mp4's (with H.264/AAC codecs) and they seem to play fine in all other browsers. We discovered that adding the "primary: 'flash'" property resolves the issue, though the flash player doesn't seem quite as nice...you can't skip ahead in the video and you can't click in the player to pause/play. However, since we're not finding any other solutions (even re-conversions of the original videos haven't yielded any different results), setting all the players to default to flash seems like it may be our only option.

So, I'm wondering if there is a way to use some kind of script to insert the "primary: 'flash'" property into all our players, perhaps from within the <head> tag so that it modifies all players across all pages. This would be ideal since we're hoping that eventually we would be able to remove this script/property once we figure out a better solution (or once Firefox or JW Player release an upgrade that resolves the issue).

Furthermore, if the script could be specific to only be called when the Firefox browser is being used by the visitor, that would be a big bonus.

Here's an example of the script for one of our players:

<div id="myvideo">Loading the player...</div>
<script type="text/javascript">
jwplayer("myvideo").setup({
file: "/video/myvideo.mp4",
image: "/images/thumbnail.jpg",
title: "My Video",
width: "100%",
aspectratio: "16:12"
});
</script>

Any help with this would be greatly appreciated!

Thank you,
JP

11 Community Answers

webmaster

User  
0 rated :

I should add that all our videos are wrapped in a div with a specific class that can be targeted:

<div class="jw-video-player">
Embedded JW Player code (see above)
</div>

jherrieven

User  
0 rated :

This seems very strange that you would be wanting to move TO Flash FOR Firefox - most people are doing the reverse as Firefox & Flash no longer work well together, and by all accounts, Chrome is going to follow suit:

http://www.jwplayer.com/blog/chrome-power-saving/

If you are sure this is what you are wanting to do, then it should be as simple as setting up some default configuration options by adding the following in the HEAD after the SCRIPT which is loading the JW cloud library:

<script>
jwplayer.defaults = {
primary: (window.InstallTrigger?"flash":"html5")
};
</script>

This "jwplayer.defaults" allows you to set default values for any parameter which is not explicitly included in the individual player embed code.

James Herrieven

===================================================
Powered by Haiku
http://powered-by-haiku.co.uk/
---------------------------------------------------
Tatami for Online Video
http://dev.powered-by-haiku.co.uk/solutions/tatami/
---------------------------------------------------
skype: JamesHerrieven
email: james[at]haiku[dot]co[dot]uk
===================================================

webmaster

User  
0 rated :

Hi James,

I wouldn't really say this is what I'm "wanting" to do, but I have yet to find a better solution. If anyone has any idea why we might be experiencing the glitches in Firefox with these .mp4 videos in the HTML5 player, I would love to hear about it.

I tried the script you shared above as described and it didn't seem to work. It looks like the players are still using HTML5 (I can tell because you have to click on the Play button in order to play the videos in the Flash player, whereas with the HTML5 player you can click anywhere in the video to pause/play). In fact, the videos don't seem to play at all right now (just getting the spinning circle). Also, it actually reverted all the players back to the default "Seven" skin (we have the "Bekle" skin selected in our account player settings), so that may be an additional clue. Is there something I need to customize from your script in order for this to work? I'm not especially familiar with javascript.

Here's what the code looks like right now in the HEAD section:

<script src="http://content.jwplatform.com/libraries/xxxxxxxx.js" type="text/javascript"></script>
<script>
jwplayer.defaults = {
primary: (window.InstallTrigger?"flash":"html5")
};
</script>

Note- I've discovered that I can just turn on the Rendering option "Always use Flash when available" in my account player settings and that basically does what I'm wanting. However, if there were a way to use your script and to specifically have it target the Firefox browser, that would be the best temporary option for us right now (unless we can pinpoint and resolve the Firefox/glitches issue).

jherrieven

User  
1 rated :

Ah ok...

Some of the things you'd said in the previous post lead me to believe you were using the "generic" cloud player, however it appears you are using the account specific cloud player - which already sets "defaults" based on the settings you select within the dashboard.

This is why your skin has reverted - because my suggestion overwrites the existing settings!

Try modifying the code I suggested to the following:

<script>
if(jwplayer.defaults) jwplayer.defaults.primary = (window.InstallTrigger?"flash":"html5");
</script>

Even having said that, the previous setup should still have rendered in Flash mode in Firefox. The way to tell with JW7 is to right-click and see whether the dialog said anything about the Flash version being used.

Are you able to share a link to an example page? It would be easier to try and figure out any issues that way.

James


webmaster

User  
0 rated :

Yes, that worked!! Very cool. Thank you.

I tried adding in some other code that I found (from this page: http://stackoverflow.com/questions/2454611/hide-an-html-element-using-javascript-only-if-browser-is-firefox) in order to target Firefox only, and at first glance it seems to work.

<script>
var firefox = /Firefox/i.test(navigator.userAgent);
if (firefox) {
if(jwplayer.defaults) jwplayer.defaults.primary = (window.InstallTrigger?"flash":"html5");
}
</script>

And yes, I can verify that right-clicking on the JW7 player while using the first script you shared does bring up the dialog that mentions Flash... which is very interesting. Do you happen to know if there is a way that I'd be able to get the Flash player to behave that way (i.e. you can click anywhere in the player to pause/play) with my current setup?

jherrieven

User  
0 rated :

Ok cool.

So... the code you've added from stackoverflow shouldn't be needed as my code already selectively targets Firefox and puts it into "flash" mode, otherwise it uses "html5" mode - you can remove your addition and you should get the same results.

Plus, ordinarily the flash player should react the same way the HTML player does - clicking anywhere within the player area causes a play/pause. Check this JW example page rendered in Flash to see this in action:

http://support.jwplayer.com/customer/portal/articles/1430218-using-hls-streaming

Do you have other scripts on the page which may be interfering with this standard behaviour?

James

webmaster

User  
0 rated :

Oh wow haha, you're right! You've already given me the perfect script :)

As for the player/clicking behavior, I went to the HLS Streaming link and it actually behaves the same way (must click the circle/triangle play button in order to start the video). Could this be related to some other aspect of my setup? I'm on a Mac 10.10.5, Firefox 40.0.3. I'm at least glad to hear that perhaps this isn't normal behavior...

jherrieven

User  
2 rated :

Interesting...

Firefox 40 on the Mac seems to be the culprit for this behaviour.

I have a couple of Mac's - one of which is OS 10.7.5 and was running Firefox 38. When I tested it, this behaved as I expected - clicking anywhere within the player initiated a play/pause.

I upgraded to FF 39 and the same was true.

Upgrading to FF 40 and suddenly the experience is different - you need to click the play button explicitly, clicking anywhere else and the player doesn't react.

Whilst on the one hand you have probably identified an issue/bug with the latest version of FF/JW Player on Mac, and knowing this things are generally working better for you, I will come back to my original observation and suggest that the configuration you've now implemented will cause a problem for users of Firefox on windows!

You might want to test that out just to be sure.

James

webmaster

User  
0 rated :

James, thanks so much for testing out the different versions of Firefox for me! Good to know that the issue seems to be specific to the combination of Firefox 40 and a Mac OS.

I've done some Firefox testing on Windows and it appears that the videos are playing ok (at least so far) with the current configuration. I'll re-post if I find any more related issues to this matter, but for now I think you've answered all my questions. Thanks again :)

If anyone comes across this post and has any thoughts about what the best (and simplest) cross-browser and cross-OS solution would be for .mp4 video playback using JW Player 7 in Firefox, I would welcome any further insights!

Todd

JW Player Support Agent  
0 rated :

Native MP4 playback is actually relatively new to Firefox for Mac. I believe they first introduced this only a few months ago in Firefox 35 or 36, so I would not be surprised if native MP4 playback in Firefox was not as stable or mature as some of the other browsers out there. (Not that Firefox is not a great browser, but some stuff takes a few iterations to get all the bugs worked out…)

I would recommend testing your MP4s by loading them directly in the browser’s address bar. If they do not play back well directly in the browser, our player is not going to be able to do anything magic to fix this. Another suggestion is to try re-encoding your MP4 in Handbrake set to the default settings (but also enable Web optimized) in case there was something in your original encode that did not play nice with Firefox.

webmaster

User  
0 rated :

Thanks Todd, that's reassuring.

I have checked the MP4s directly in the browser (bypassing JW Player) and can confirm that the issues/glitches are still present, so that makes sense that JW Player wouldn't be able to do anything more to fix this.

Also, for anyone else that comes across this post, I have tried many many combinations of encoding settings with Handbrake (including the default with and without the "Web optimized" feature selected) and have yet to find the right combination that resolves the glitches. Aside from testing the different settings, I'm not sure how else to pinpoint which aspect of the file is contributing to the issue. Any advice would be gratefully received, though I imagine this could be a topic for a different forum :)

This question has received the maximum number of answers.