I want a simple code to play video from rtmp stream for my android application project

R_Hear picture R_Hear · Sep 12, 2012 · Viewed 17.9k times · Source

I have project about Video on Demand via Android TV Box. I have problem,I can not find open source of RTMP player. Had someone can help me or guide me about the rtmp player source code ?

I use red5 to stream and buil for android 2.2(froyo).

Answer

Athul Harikumar picture Athul Harikumar · Sep 12, 2012

using RTSP

 public class PlayVideoRemote extends Activity
 {
private VideoView vView;
private String vSource;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{ 
    //sets the Bundle
    super.onCreate(savedInstanceState);
    //sets the context 
    setContentView(R.layout.main);

    //get the VideoView from the layout file
    vView = (VideoView)findViewById(R.id.vview);

    //use this to get touch events
    vView.requestFocus();

    //loads video from remote server
    //set the video path
    vSource ="rtsp://v6.cache1.c.youtube.com/CjYLENy73wIaLQnF4qJzpSt4nhMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYMDFmvL1wMysTQw=/0/0/0/video.3gp";
    //set the video URI, passing the vSource as a URI
    vView.setVideoURI(Uri.parse(vSource));

    //enable this if you want to enable video controllers, such as pause and forward
    vView.setMediaController(new MediaController(this));

    //plays the movie
    vView.start();
}
}

for RTMP refer this Convert video Input Stream to RTMP