问题
I'm trying to play a live RTSP video (from rtsp://media2.tripsmarter.com/LiveTV/BTV/
) using VideoView
, and here's my code:
public class ViewTheVideo extends Activity {
VideoView vv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vv = (VideoView) this.findViewById(R.id.VideoView);
Uri videoUri = Uri.parse("rtsp://media2.tripsmarter.com/LiveTV/BTV/");
vv.setMediaController(new MediaController(this));
vv.setVideoURI(videoUri);
vv.requestFocus();
vv.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
vv.start();
}
});
}
}
This code works fine on Samsung Galaxy Y, and even on the emulator too, but it doesn't run on Samsung Galaxy S2 (Sorry, this video cannot be played)! Both the devices and the emulator are running Gingerbread.
Here's the LogCat messages:
07-30 10:48:28.310: I/MediaPlayer(24573): uri is:rtsp://media2.tripsmarter.com/LiveTV/BTV/
07-30 10:48:28.310: I/MediaPlayer(24573): path is null
07-30 10:48:28.310: D/MediaPlayer(24573): Couldn't open file on client side, trying server side
07-30 10:49:13.025: W/MediaPlayer(24573): info/warning (1, 26)
07-30 10:49:13.025: I/MediaPlayer(24573): Info (1,26)
07-30 10:49:13.075: E/MediaPlayer(24573): error (1, -1)
07-30 10:49:13.075: E/MediaPlayer(24573): Error (1,-1)
07-30 10:49:13.075: D/VideoView(24573): Error: 1,-1
I could not figure out what those error codes are about.
Is there any issues with Samsung Galaxy S2 with streaming? I also tried with a YouTube stream (rtsp://v2.cache2.c.youtube.com/CjgLENy73wIaLwm3JbT_9HqWohMYESARFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNg_vSmsbeSyd5JDA==/0/0/0/video.3gp
), but it's all the same.
Update: Later I recorded a video with Galaxy S2 (Format: 3GP, Encoder: H.264, Bitrate: 56kbps, Framerate: 15fps) and streamed the video from the PC using VLC media player. This one can be viewed in Galaxy S2 (and others) without any error. However, no other video could be played on S2.
回答1:
@Andro Selva this is how I streamed his link
video_url = "rtsp://media2.tripsmarter.com/LiveTV/BTV/";
try {
videoView =(VideoView)findViewById(R.id.videoView1);
//Set video link (mp4 format )
Uri video = Uri.parse(video_url);
videoView.setVideoURI(video);
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
videoView.start();
}
});
}catch(Exception e){
}
来源:https://stackoverflow.com/questions/11715702/cannot-play-rtsp-video-in-videoview-in-samsung-galaxy-s2