0 Replies Latest reply on Feb 12, 2013 10:13 AM by ymichel

    How to pause/resume a live stream (rtmp)

    ymichel

      Hi,

       

      I'm trying to pause and resume a live stream with elemental OSMF components. The pause action works but not the resume...Someone can explain it ?

       

      Here is my code :

       

      package
      {
          import flash.text.*;
          import flash.display.*;
          import flash.events.*;
          import flash.utils.*;
          import flash.net.*;
      
      
          import org.osmf.containers.*;
          import org.osmf.media.*;
          import org.osmf.elements.*;
          import org.osmf.traits.*;
          import org.osmf.net.*;
          import org.osmf.events.*;
          import org.osmf.layout.*;
      
      
          public class Application extends Sprite
          {   
              private static const STREAM : String = 'YOUR_LIVE_RTMP_URL';
      
      
              public function Application()
              {   
                  var mediaElement : MediaElement = new DefaultMediaFactory().createMediaElement(new StreamingURLResource(STREAM, StreamType.LIVE)); 
      
      
                  var mediaPlayer : MediaPlayer = new MediaPlayer(mediaElement);
      
      
                  var mediaContainer : MediaContainer = new MediaContainer();
                  mediaContainer.addMediaElement(mediaElement);
                  addChild(mediaContainer);
      
      
                  stage.addEventListener(MouseEvent.CLICK, function(event : MouseEvent) : void
                  {   
                      if (mediaPlayer.paused)
                      {   
                          mediaPlayer.play();
                      }   
                      else if (mediaPlayer.playing)
                      {   
                          mediaPlayer.pause();
                      }   
                  }); 
              }   
          }   
      }
      

       

      Thanks for your help.