android rtsp live stream - "Can't play this video"
<pre><code>public class MainActivity extends Activity
{
    VideoView vv;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        vv = (VideoView)findViewById(R.id.videoView);

        Uri uri;
        uri=Uri.parse("rtsp://user:pass@192.168.x.x:554/cam/realmonitor?channel=1&amp;subtype=1");
        vv.setVideoURI(uri);
        vv.start();
    }
}
</code></pre>

<p>I am using the above code, trying to play my IP live camera stream. The used URI works when used in VLC player. I have Internet permissions set inside my manifest too. But when I run the app on my emulator, or live device, I get the "Can't play this video" error.</p>

<p>The error that pops up in logcat is:</p>

<pre><code>08-31 09:21:15.602 2487-2487/package D/MediaPlayer: Couldn't open file on client side, trying server side
08-31 09:21:15.612 2487-2503/package W/MediaPlayer: info/warning (701, 0)
08-31 09:21:15.666 2487-2502/package E/MediaPlayer: error (1, -2147483648)
08-31 09:21:15.725 2487-2487/package E/MediaPlayer: Error (1,-2147483648)
08-31 09:21:15.725 2487-2487/package D/VideoView: Error: 1,-2147483648
</code></pre>

<p>I have tried setting it up with media player aswell:</p>

<pre><code>public class MainActivity extends Activity implements MediaPlayer.OnPreparedListener, SurfaceHolder.Callback
{
    final static String USERNAME = "user";
    final static String PASSWORD = "pass";
    final static String RTSP_URL = "rtsp://192.168.x.x:554/cam/realmonitor?channel=1&amp;subtype=00";

    private MediaPlayer _mediaPlayer;
    private SurfaceHolder _surfaceHolder;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        Window window = getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        window.setBackgroundDrawableResource(android.R.color.black);
        setContentView(R.layout.activity_main);
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
        _surfaceHolder = surfaceView.getHolder();
        _surfaceHolder.addCallback(this);
        _surfaceHolder.setFixedSize(320, 240);
    }
    @Override
    public void surfaceChanged(SurfaceHolder sh, int f, int w, int h) {}
    @Override
    public void surfaceCreated(SurfaceHolder sh) {
        _mediaPlayer = new MediaPlayer();
        _mediaPlayer.setDisplay(_surfaceHolder);
        Context context = getApplicationContext();
        Map&lt;String, String&gt; headers = getRtspHeaders();
        Uri source = Uri.parse(RTSP_URL);
        try {
            _mediaPlayer.setDataSource(context, source, headers);
            _mediaPlayer.setOnPreparedListener(this);
            _mediaPlayer.prepareAsync();
        }
        catch (Exception e) {}
    }
    @Override
    public void surfaceDestroyed(SurfaceHolder sh) {
        _mediaPlayer.release();
    }
    private Map&lt;String, String&gt; getRtspHeaders() {
        Map&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
        String basicAuthValue = getBasicAuthValue(USERNAME, PASSWORD);
        headers.put("Authorization", basicAuthValue);
        return headers;
    }
    private String getBasicAuthValue(String usr, String pwd) {
        String credentials = usr + ":" + pwd;
        int flags = Base64.URL_SAFE | Base64.NO_WRAP;
        byte[] bytes = credentials.getBytes();
        return "Basic " + Base64.encodeToString(bytes, flags);
    }
    @Override
    public void onPrepared(MediaPlayer mp) {
        _mediaPlayer.start();
    }
}
</code></pre>

<p>the above code has been taken from <a href="https://ijoshsmith.com/2014/01/25/video-streaming-from-an-ip-camera-to-an-android-phone/" rel="nofollow">here</a>
but none of them work.
I've also tried the Vitamio library with no results. Nothing I do seems to be working.</p>

<p>Am I missing any small details somewhere? I'm assuming the URI is fine since that works in VLC player just fine. At some point the emulator was also giving a "java.io.FileNotFoundException: No content provider", but no longer.</p>

<p>At one point, I was thinking that maybe the authentication is a problem, so I streamed the IP camera using VLC, without user/pass, and tried to connect, but that didn't work either, so I'm assuming it is successfully authenticating.</p>

<p>I have also tried passing the url in as "rtsp://user:pass@192.168.x.x:554/", that also works in VLC player. But not in my app.</p>

<p>I have tried everything I was able to find, with no success. If anyone is able to help out, would be much appreciated!</p>

<p>Edit 1: The VideoView has been able to successfully play pre-recorded clips such as "rtsp://mpv.cdn3.bigCDN.com:554/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4"
same with vitamio and mediaplayer.</p>