I am developing the android application to stream online video channels. Now, i want to stream from rtsp://62.220.122.4/tv1 and i use the code as below to stream from this link :
import java.io.IOException;
import android.widget.MediaController;
import android.widget.VideoView;
import android.app.Activity;
import android.content.res.Configuration;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
public class TVStreamerActivity extends Activity {
private VideoView mVideoView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(mVideoView);
mVideoView.setVideoURI(Uri.parse("rtsp://62.220.122.4/tv1"));
mVideoView.setMediaController(mediaController);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer arg0) {
mVideoView.start();
Log.e("Runnbale Thread : Run MediaPlayer",
"MediaPlayer Prepared");
}
});
mVideoView.requestFocus();
}
}
and in the videoview.xml is :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.widget.VideoView
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
All things are okay, but when i run the application, after a while i see the Error (1, -16) in LogCat and the message Sorry, this media cannot be played is displayed in android device.
Could any one please give me a solution to solve this problem ?
EDIT: In the manifest i set the android:minSdkVersion="10", and i have tested it on Galaxy Ace S5830 (Android 2.3.6)
Thanks in advance :)