JWA Player API javaScript not working

I am using jwplayer.version = '5.10.2295' and chrome 25 browser.

My code:

jwplayer('container').setup({
    file: 'path...',
    width: '300px',
    height: '100px',
    autostart: true,
    modes: [
        { type: 'html5' },
        { type: 'flash', src: 'path...' }
    ]
});

      

When the page is loaded, my resource (mp4 video file) starts to display correctly - this is normal. But there is no reaction to simple jwplayer JS API methods like jwplayer (). Stop (). And some of the controls are not available (play, top, search), but the "full screen" button works just like the volume button.

And the most interesting thing is that the js api and control buttons are available for a few seconds after the video starts playing (if the browser cache is cleared) and then there is no response to the interaction. But some method works correctly all the time (jwplayer (). For example, setFullscreen ()).

ps I saw a related question , but the answer is not deep for me.

+2


source to share


2 answers


I found a solution.

My video file does not have a specified extension in the path (I have "path / to / file" instead of "path / to / file.mp4"), and this fact is ripped to some extent in the depths of jwPlayer. We need to specify the type of file we are working with:



jwplayer('container').setup({
    file: 'path/to/file-with-no-extension',
    width: '300px',
    height: '100px',
    autostart: true,
    type: 'video',  //helps jwplayer to determine how to handle our resource with no extension
    modes: [
        { type: 'html5' },
        { type: 'flash', src: 'path...' }
    ]
});

      

This is the solution.

+2


source


Download jwplayer6 from http://www.longtailvideo.com/jw-player/download/

Place these files in a specific directory: -

  • app / assets / jwplayer / jwplayer.flash.swf
  • vendor / assets / javascripts / jwplayer.js
  • vendor / assets / javascripts / jwplayer.html5.js

Then add this line to application.js

//= require jwplayer
//= require jwplayer.html5

      



On the page where you play the video add these lines

<script type="text/javascript">jwplayer.key="YOUR_JWPLAYER_KEY";</script>
<div id="video">Loading the player ...</div>
<script type="text/javascript">
jwplayer("video").setup({
    flashplayer: "<%=asset_path('jwplayer.flash.swf')%>",
    file: "<%= file_path %>",
    height: 360,
    width: 640,
    analytics: {
        enabled: false,
       cookies: false
   }
});

      

http://account.longtailvideo.com/#/home from where you can get your free self-service key when you register from Get your license key part.

+1


source







All Articles