Rtsp streaming using VideoView and MediaPlayer

I want to develop an android app that will play a rtsp link from a local server but the tablet screen is blank .... showing nothing I've tried both classes VideoView

and MediaPlayer

. Work well with rtp youtube channels with .3gp extension, but not working on the above url. Below is my code

public class WifiManagerActivity extends Activity {

private WifiManager  customWifiManager;
private VideoView mu;
private String path;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        wifiSettings();
    }

    private void wifiSettings() {
        mu  = (VideoView) findViewById(R.id.ttl);
        TextView notify = (TextView) findViewById(R.id.wifi_state);
        customWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
                if(customWifiManager.isWifiEnabled()){
            Toast.makeText(this, "Your wifi is On now enjoy " +
                    "live streaming", Toast.LENGTH_SHORT).show();
            notify.setTextColor(Color.GREEN);
            showVideo();
        }else{
        Toast.makeText(this, "Turn your Wifi On", Toast.LENGTH_SHORT).show();
        customWifiManager.setWifiEnabled(true);
        //two second wait here
        showVideo();
        }

    }

    private void showVideo() {


        Authenticator.setDefault(new MyAuthenticater());
        String path = "rtsp://192.168.1.155:554/3g";
        mu.setVideoURI(Uri.parse(path));
        mu.setMediaController(new MediaController(this));
        mu.requestFocus();
        mu.start();
    }
}

      

+3


source to share


1 answer


There are several factors that can affect the correctness of your stream playback:

  • check if your stream is valid and playable (using for example a separate VLC instance)
  • if that works, check logcat for any errors / warnings related to either the RTSP connection or the video stream. Look for tags like: MediaPlayer, ARTSPConnection, MyHandler, ASessionDescription, ACodec.


This should get you started.

0


source







All Articles