Search code examples
javascriptjwplayer

Get title of currently playing video


Current I am working in codeigniter project, in that I need to integrate Jw player 5 with playlist. I just created plalist which are dynamic and its working fine. So, now I want get title or some other details of currently playing videos. I tried a lot, but no luck. I just posted here a bit of javascript code, I get that from Jw player sites forum, but it is not working for me. I just tried by static. Here is the code ..

<!DOCTYPE HTML>
<html>

        <div id="mediaplayer">
    </div>

    <script type="text/javascript" src="http://172.16.1.181:85/test/player1/jwplayer.js"></script>


            <script type="text/javascript">
                    jwplayer("mediaplayer").setup({
            flashplayer: "http://172.16.1.181:85/test/player1/player.swf",
                    height:"350",
                    width:"500",
                    autostart: "true",
                    'playlist': [{
            'file': 'http://172.16.1.181:85/test/flash/test.flv',
                    'image': 'http://172.16.1.181:85/test/images/no_image.gif',
                    'title': 'Test_video_1'
            },
            {
                'file': 'http://172.16.1.181:85/test/flash/test.flv',
                        'image': 'http://172.16.1.181:85/test/images/no_image.gif',
                        'title': 'Test_video_2'
                }
            ],
                    repeat: 'list'
            });

        </script>



<p>In the body:</p>
      <div id="nowplaying">

      <script type="text/javascript">
      jwplayer().getPlaylistItem().index
      </script>
      </div>


</html>

The player playing the video well. But I Dont know how to get currently playing video's details..Please help me guys..


Solution

  •  <div id="nowplaying">
        <script type="text/javascript">
           var current = jwplayer().getPlaylistItem();
           console.log(current.title);
        </script>
    </div>