0
votes

I am trying to build an app to play video from an URL, I am using rtsp, I have tried with most of the examples that I have found online, however none has worked.. This is my code so far in the client:

package com.example.rtsp_player;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String uri = "rtsp://192.168.2.170:5544/";
    VideoView v = (VideoView) findViewById( R.id.videoView );
    v.setVideoURI( Uri.parse(uri) );
    v.setMediaController( new MediaController( this ) );
    v.requestFocus();
    v.start();
}
}

And this is how I am broadcasting using vlc: :sout=#transcode{vcodec=h264,vb=800,fps=30,width=320,height=180,acodec=mp4a,ab=128,channels=2,samplerate=22050} :rtp{sdp=rtsp://192.168.2.170:5544/}**

I don't know if it is because of the codecs or what..

2
mmm I guess nobody has an answer...Santiago Molina

2 Answers

0
votes
myVideoView = (VideoView) findViewById(R.id.myview);
myVideoView.setVideoPath("rtsp://SERVER_IP_ADDR:5544/");
myVideoView.setMediaController(new MediaController(this));

this may help

0
votes

Add this line to your code.

Uri uri = Uri.withAppendedPath(MediaStore.Video.Media.INTERNAL_CONTENT_URI,"1");

Change the code like this and try.

String uri = "rtsp://192.168.2.170:5544/";
VideoView v = (VideoView) findViewById( R.id.videoView );
Uri uri_add = Uri.withAppendedPath(MediaStore.Video.Media.INTERNAL_CONTENT_URI,"1");
v.setVideoURI( uri_add.parse(uri) );
v.setMediaController( new MediaController( this ) );
v.requestFocus();
v.start();