baby Iype baby Iype -4 years ago 95
Android Question

how to stream a video from an RTSP link

I have to stream video from an RTSP link from into a TextureView.


"rtsp://192.168.1.1:6664/streamhdv"


is my path. I tried with URL connection method, which cannot be applied to RTSP

Please help me to stream the video

Answer Source

You can use setDataSource(path) method of MediaPlayer Class to load the url and streaming will work.

Please refer this:

     private static final String path = "rtsp://192.168.1.1:6664/streamhdv";
               .
               .
               .
    private void prepareTextureView(SurfaceTexture surface) {
            Surface s = new Surface(surface);
            mediaPlayerTexture = new MediaPlayer();
            mediaPlayerTexture.setSurface(s);
            try {
                mediaPlayerTexture.setDataSource(path);

            } catch (IOException e) {
                e.printStackTrace();
            }
            mediaPlayerTexture.prepareAsync();
            mediaPlayerTexture.setOnPreparedListener(this);
        }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download