Search code examples
javaandroidandroid-mediaplayerandroid-video-player

Android: Play RTSP video from URL


I'm trying to play an RTSP url in my android app, using the following code:

String url = "rtsp://mobilestr1.livestream.com/livestreamiphone/nyc";
                    Uri uri = Uri.parse(url);
                    System.out.println("URL="+url);
                    startActivity(new Intent(Intent.ACTION_VIEW, uri));

However an alert dialog pops up after a few seconds saying "Unable to play video". I have tried several RTSP urls and none of them work. What am I doing wrong?

Thanks


Solution

  • That stream is h264 MPEG-4 AVC Part 10. Which doesnt work on most android devices. This page has a list of what does work. But essentially you need an MPEG-4 Baseline stream.

    http://developer.android.com/guide/appendix/media-formats.html#recommendations

    If you open the stream in VLC and then : Window > Media Information > Codec Details you can verify this info as well