检查视频是否正在流媒体 [英] check if video is streaming

查看:143
本文介绍了检查视频是否正在流媒体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有来自 http://www.tpai.tv/live 的此流,但您可以现在看,它下来,我需要检查流是否正在播放,如果没有播放其他东西。

I have this stream from http://www.tpai.tv/live but as you can see now, its down, i need to check if stream is playing and if not to play other thing.

这是流媒体代码:

<base href="http://www.jet7angola.com/entretenimento/tpa-internacional-online-directo.html">
<script src="http://www.jet7angola.com/tpa/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="/tpai/jquery-blink.js+jquery.mousewheel.js+jquery.rollover.js+jquery.jscrollpane.min.js+jquery.tools.min.js+jquery.fancybox-1.3.4.pack.js.pagespeed.jc.UjuzPwaNVv.js"></script>
<script>eval(mod_pagespeed_68xhNxTuZL);</script>
<script>eval(mod_pagespeed_20IR7GdmNb);</script>
<script>eval(mod_pagespeed_Bj_7y8YV5J);</script>
<script>eval(mod_pagespeed_kvFbwG5fFn);</script>
<script>eval(mod_pagespeed_5Z2gomwGm9);</script>
<script>eval(mod_pagespeed_u84aD23v_6);</script>
<script src="/tpai/jwplayer.js.pagespeed.jm.KvxnOnM4Zh.js" type="text/javascript"></script>
<script src="/tpai/swfobject.js+common.js.pagespeed.jc.nCJR8-Q7ly.js"></script>
<script>eval(mod_pagespeed_4NJ4whyEXd);</script>
<script>eval(mod_pagespeed_LzOFG2pWFp);</script>

<div align="justify" id="livemedia" style="width: 621px; height: 384px;">
    <script type="text/javascript">
    jwplayer("livemedia").setup({"skin":"http://www.tpai.tv/swf/jwplayer/skins/nacht/nacht.zip","id":"livemediaplayer","autostart":"true","rtmp.subscribe":"true","file":"http://www.tpai.tv/tpai_rtmp_dynamic_streaming.xml","controlbar":"none","volume":100,"width":"100%","height":"100%","modes":[{type:"flash",src:"http://www.tpai.tv/swf/jwplayer/player.swf"}]});
    </script>
</div>

更新...

            <div align="justify" id="livemedia" style="width: 621px; height: 384px;">
                <script type="text/javascript">

                .onReady(function(){

                    if(this.getState() == "playing"){
                        jwplayer("livemedia").setup({"skin":"http://www.tpai.tv/swf/jwplayer/skins/nacht/nacht.zip","id":"livemediaplayer","autostart":"true","rtmp.subscribe":"true","file":"http://www.tpai.tv/tpai_rtmp_dynamic_streaming.xml","controlbar":"none","volume":100,"width":"100%","height":"100%","modes":[{type:"flash",src:"http://www.tpai.tv/swf/jwplayer/player.swf"}]});
                    } else {
                        <embed style="vertical-align: middle;width:100%;height:100%;" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.rtp.pt/play/player.swf?v3" id="obj_player_prog" name="obj_player_prog" quality="high" allowfullscreen="true" wmode="opaque" allowscriptaccess="always" allownetworking="all" class="embed-responsive-item" flashvars="streamer=rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live&amp;file=2ch27h264&amp;image=undefined&amp;controlbar=over&amp;skin=http://www.rtp.pt/swfjs/skin/fk.zip&amp;autostart=true&amp;plugins=http://programas.rtp.pt/play/ova-jw-play.swf,timeslidertooltipplugin-3&amp;stretching=exactfit&amp;config=http://www.rtp.pt/services/rtpplay/pub/config_page_play/566651108/rtp-play/direto/canais-tv/rtpafrica&amp;abouttext=© RTP.PT&amp;screencolor=0x000000&amp;aboutlink=http://www.rtp.pt/">
                    }    
                });

                </script>
            </div>  


推荐答案

你想要使用 getState()返回播放器的当前播放状态:

You'll want to use getState() which returns the player's current playback state:

jwplayer("livemedia").setup({

    // Setup parameters

}).onReady(function(){

    if(this.getState() == "playing"){
        // WOO HOO: (Don't cross the streams!)
    } else {
        //THE STREAM IS DOWN!
    }    
});



可用选项包括:




  • 空闲:播放未开始或播放停止(由于stop()调用或错误)。播放或错误图标
    在显示屏中可见。

  • 缓冲:用户按下播放,但必须有足够的数据才能开始播放首先加载。缓冲图标显示在
    显示中。

  • 正在播放:视频当前正在播放。显示屏中未显示任何图标。

  • 已暂停:视频当前已暂停。播放图标显示在显示屏上。

  • The available options are:

    • idle: either playback has not started or playback was stopped (due to a stop() call or an error). Either the play or the error icon is visible in the display.
    • buffering: user pressed play, but sufficient data to start playback has to be loaded first. The buffering icon is visible in the display.
    • playing: the video is currently playing. No icon is visible in the display.
    • paused: the video is currently paused. The play icon is visible in the display.
    • 在这里查看jwplayer API参考:

      Have a look at the jwplayer API Reference here:

      https://support.jwplayer.com/customer/portal/articles/1413089-javascript-api-reference#playback

      这篇关于检查视频是否正在流媒体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆