Skip to main content
Participant
July 11, 2011
Question

Can't play live rtmp stream on mobile

  • July 11, 2011
  • 1 reply
  • 4161 views

I'm trying to play live audio from an rtmp stream on a mobile device (Android) that was built with Flash Builder 4.5.1.  I can hear the stream with a Flex 3 project so I know it's playing.  I also replaced the URL with a recorded file and it played.  Can anyone tell me what I've done wrong?

In the View:

private var instructorMedia:MediaPlayerExample; 

var rtmpPath:String = "rtmp://myServer/eTutor";

var rtmpSession = "host9938850";

instructorMedia = new MediaPlayerExample(rtmpPath + "/" + rtmpSession);

In the Class

package views
{
import flash.display.Sprite;

import org.osmf.containers.MediaContainer;
import org.osmf.elements.AudioElement;
import org.osmf.events.TimeEvent;
import org.osmf.media.MediaPlayer;
import org.osmf.media.URLResource;

public class MediaPlayerExample extends Sprite
{
  private var mediaPlayer:MediaPlayer;
 
  public function MediaPlayerExample(URL:String)
  {           
   super();
  
   mediaPlayer = new MediaPlayer();
   var audioElement:AudioElement = new AudioElement();
   audioElement.resource = new URLResource(URL);
  
   mediaPlayer.volume = .7;
   mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onTimeUpdated);       
   mediaPlayer.addEventListener(TimeEvent.DURATION_CHANGE, onTimeUpdated);
   mediaPlayer.autoPlay = true;
   mediaPlayer.media = audioElement;   
  }
 
  private function onTimeUpdated(event:TimeEvent):void
  {
   trace('time: ' + mediaPlayer.currentTime + ' duration: ' + mediaPlayer.duration);
  }
}
}

    This topic has been closed for replies.

    1 reply

    Participant
    July 12, 2011

    Any parameters that would indicate a live stream necessary?

    Participating Frequently
    July 13, 2011

    Hi,

    I tried playing a stream in my URL by hardcoding the string URL and it worked fine.

    Can you check if the stream is playing in the hosted player : http://osmf.org/dev/1.6-sprint-3/StrobeMediaPlayback.html

    Append the stream name as ?rtmp://<server-ip>/<application>/format:streamname.

    Participant
    July 14, 2011

    I got it with the following code...  It was "StreamingURLResource" that gave me the option to do live.  Now it's working fine.

    public class MediaPlayerExample extends Sprite
    {
      private var mediaPlayer:MediaPlayer;
     
      public function MediaPlayerExample(URL:String)
      {           
       super();
      
       //URL = "rtmp://cp67126.edgefcs.net/ondemand/mediapm/strobe/content/test/SpaceAloneHD_sounas_640_500_short";
       //URL = "rtmp://76.242.102.193/eTutor/0_738_3_9_5_23_2011_5_59_36_PM/LS1";
      
       mediaPlayer = new MediaPlayer();
       var audioElement:AudioElement = new AudioElement();
       audioElement.resource = new StreamingURLResource(URL, StreamType.LIVE_OR_RECORDED);

       mediaPlayer.volume = .7;
       mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onTimeUpdated);       
       mediaPlayer.addEventListener(TimeEvent.DURATION_CHANGE, onTimeUpdated);
       mediaPlayer.addEventListener(TimeEvent.COMPLETE,onTimeEventComplete);
       mediaPlayer.autoPlay = true;
       mediaPlayer.media = audioElement;
      }