Search code examples
javascriptjqueryvideomp4jplayer

Open mp4 video with JPlayer in Opera/Firefox


To play MP4 video i use the following script:

   $("#jplayer").jPlayer("setMedia", {
        m4v: "./videos/test.mp4"
    }).jPlayer("play", 0);

The player is initialized with following code:

$("#jplayer").jPlayer({
        swfPath: "./jplayer/",
        supplied: "m4v",
        solutions: "flash, html",
        size: {
            width: "640px",
            height: "460px"
        },
        nativeVideoControls: {
            all: /./
        },
    });

If i open the video in Chrome/IE- everything works fine. But in Opera/Firefox flash is loading(flash embedded code appears on the page), but video is not and nothing plays. Here is the code that is loading in jplayer div in Opera/Firefox

<div id="jplayer" class="jp-jplayer" style="width: 640px; height: 460px; display: block;">
<img id="jp_poster_1" style="width: 640px; height: 460px; display: none;">
<object id="jp_flash_1" width="1" height="1" data="./jplayer/Jplayer.swf" type="application/x-shockwave-flash" style="width: 0px; height: 0px;">
<param name="flashvars" value="jQuery=jQuery&id=jplayer&vol=0.8&muted=false">
<param name="allowscriptaccess" value="always">
<param name="bgcolor" value="#000000">
<param name="wmode" value="opaque">
</object>
</div>

Can you suggest what to try? Cant figure out what can cause such problem if the path to flash player is correct.


Solution

  • My problem was that flash had no time to initialize and set media. Adding setMedia to player initalization into ready event helped.