【问题标题】:Get title of currently playing video获取当前播放视频的标题
【发布时间】:2013-11-15 11:14:45
【问题描述】:

目前我正在从事 codeigniter 项目,因为我需要将 Jw player 5 与播放列表集成。我刚刚创建了动态且工作正常的 plalist。所以,现在我想获取当前播放视频的标题或其他一些详细信息。我尝试了很多,但没有运气。我刚刚在这里发布了一些 javascript 代码,我从 Jw 播放器网站论坛获得,但它不适合我。我只是通过静态尝试。这是代码..

<!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>

播放器播放的视频很好。但我不知道如何获取当前正在播放的视频的详细信息..请帮帮我..

【问题讨论】:

标签: javascript jwplayer


【解决方案1】:
 <div id="nowplaying">
    <script type="text/javascript">
       var current = jwplayer().getPlaylistItem();
       console.log(current.title);
    </script>
</div>

【讨论】:

  • 谢谢@alex。有效。但对事件的改动很小。
【解决方案2】:

您不需要使用任何第三方框架来执行此操作。你只需要一些 JavaScript 基本函数...

var video = document.getElementById('vid');
var video_src = video.src;
// The above code gets the source of video
var name_with_ext = video_src.split('/');
// This returns an array 
name_with_ext = name_with_ext[name_with_ext.length - 1];
// This returns the name of the file with the extension
var video_ext = name_with_ext.split('.');
// This returns an array too
video_ext = video_ext[video_ext.length -1];
// This returns the extension of video
var name = name_with_ext.replace(video_ext, '')
//This returns the name
&lt;video src="vid.mp4" id="vid" class="vid"&gt;&lt;/video&gt;

【讨论】:

    猜你喜欢
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-20
    • 2014-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多