Kiran
Kiran

Reputation: 11

RTP Stream media player on Android 4.2

I am trying to write a simple app using VideoView to play a RTSP stream on an Android device. I found that the MediaPlayer class can play RTSP directly.

Below is a snippet of the code i am using in the app:

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rtpplayback);

        final VideoView vidView = (VideoView)findViewById(R.id.video_view);
        MediaController vidControl = new MediaController(this);
        vidControl.setAnchorView(vidView);
        vidView.setMediaController(vidControl);
        vidView.setVideoPath("rtsp://media.smart-streaming.com/mytest/mp4:sample_phone_300k.mp4");
        vidView.start();
    }

I got the rtsp link from here, so i assume no issues there.

However when i try running this app on the device, i get the "Can't play this video" error.

From the adb logs, i see:

E/MediaPlayer-JNI﹕ QCMediaPlayer mediaplayer NOT present
D/MediaPlayer﹕ Couldn't open file on client side, trying server side
E/MediaPlayer: error (1, -2147483648)
E/MediaPlayer: Error (1,-2147483648)
D/VideoView: Error: 1,-2147483648

I have already added uses-permission to include INTERNET permission in my Android Manifest file.

Could it be an issue with the URI itself? I tried with multiple URIs but with the same result. I found some links on stackoverflow providing ways to convert Youtube links to RTSP links, but those seems to be deprecated now(it doesnt work).

Any ideas/suggestions? On a related note, if you are aware of any known RTSP links, please do suggest.

Upvotes: 0

Views: 716

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 1306

Possible Solution is play with native player

String videoURL = "rtsp://media.smart-streaming.com/mytest/mp4:sample_phone_300k.mp4"; 
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(videoURL));
startActivity(intent);

Upvotes: 1

Related Questions