Skip to main content
November 20, 2010
Question

How to set the flvplayback properly so that it can play both live and recorded videos?

  • November 20, 2010
  • 1 reply
  • 2615 views

I've read the reference here,but it seems to me that I can only make it work with live OR recorded videos.

How can I make it work with both live AND recorded videos?

    This topic has been closed for replies.

    1 reply

    Adobe Employee
    November 22, 2010

    Hi,

    You can use following actionscript code in the action script panel of flvplayback component and here you can set isLive and isDVR to false to play recorded videos and use the same as existing one to play live:

    import flash.utils.setInterval;
    import flash.utils.setTimeout;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.*;

    import fl.video.FLVPlayback;
    import fl.video.VideoPlayer;
    import fl.video.VideoEvent;

    import flash.display.MovieClip;

    VideoPlayer.iNCManagerClass = fl.video.NCManagerNative;
    vidplayer.isLive = true;
    vidplayer.isDVR = false; 
    vidplayer.dvrSnapToLive = false;
    vidplayer.source = "rtmp://localhost/live/sample";

    var videoplayer:VideoPlayer;
    var flvplayback:FLVPlayback;
    flvplayback = FLVPlayback(this.getChildByName("vidplayer"));
    videoplayer = flvplayback.getVideoPlayer(0);
    setTimeout(initMonitor,5000);

    function initMonitor():void
    {
    if (videoplayer.netStream!=null)
    {
      trace("Video is playing!!");
    }
    else
    {
      trace("Main.as : " + "Not connected to FMS yet - Trying again ....")
      setTimeout(initMonitor,5000);
    }     
    }

    Hope this helps.

    Regards,

    Amit

    December 3, 2010

    Since you have this line:

    vidplayer.isLive = true;

    I think it will only work for live streams,not for recorded stream.

    My target is to make it work no matter it's live or recorded,and I've no idea whether the stream is live or recorded before hand.

    Adobe Employee
    December 3, 2010

    Hi,

    I think you can achieve this but you need to keep the source file for fl.video package and then you can do this by modifying the videoplayer.as file where actually we make netstream call. So there you can specify -2 option as second parameter in ns.play() so it try to play first live and if it doesnot get that then it will play vod. So here goes the code :

    fl\video\VideoPlayer.as

    ---------------------------------

    flvplayback_internal function _play(startTime:int=0, endTime:int=-1):void {
       . 

       .

       .
       if(_ncMgr.isDynamicStream == true) {
            _playDynamicStream(startTime, endTime);
       }

       else {

            //_ns.play(_ncMgr.streamName, (_isLive) ? -1 : startTime , endTime);
            _ns.play(_ncMgr.streamName, -2 , endTime);
       }
      }

    Regards,

    Amit