2012-07-30 24 views
5

Tôi đang cố gắng để chơi một RTSP video trực tiếp (từ rtsp://media2.tripsmarter.com/LiveTV/BTV/) sử dụng VideoView, và đây là mã của tôi:Không thể chơi RTSP video trong VideoView trong Samsung Galaxy S2

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(); 
      }   
     }); 
    } 
} 

Mã này hoạt động tốt trên Samsung Galaxy Y , và thậm chí trên trình giả lập, nhưng nó không chạy trên Samsung Galaxy S2 (Xin lỗi, video này không thể phát)! Cả hai thiết bị và trình giả lập đều đang chạy Gingerbread.

Dưới đây là những thông điệp LogCat:

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 

tôi không thể tìm ra những gì các mã lỗi là về.

Có vấn đề gì với Samsung Galaxy S2 khi phát trực tiếp không? Tôi cũng đã thử với luồng YouTube (rtsp://v2.cache2.c.youtube.com/CjgLENy73wIaLwm3JbT_9HqWohMYESARFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNg_vSmsbeSyd5JDA==/0/0/0/video.3gp), nhưng tất cả đều giống nhau.

Cập nhật: Sau đó tôi ghi lại một đoạn video với Galaxy S2 (Định dạng: 3GP, Encoder: H.264, Bitrate: 56Kbps, Tốc độ khung hình: 15fps) và xem trực tiếp video từ máy PC sử dụng VLC media player. Điều này có thể được xem trong Galaxy S2 (và những người khác) mà không có bất kỳ lỗi nào. Tuy nhiên, không thể phát video khác trên S2.

+0

không hỗ trợ 2.3.x rtsp? Tôi nghĩ rằng nó hình thức 3.x và như vậy. –

+0

Có wifi hoặc gprs của thiết bị đang ON .... ?? – Yash

+0

Tôi đang thử nghiệm qua Wi-Fi. – 0605002

Trả lời

-2

@Andro Selva đây là cách tôi xem trực tiếp liên kết của mình

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){ 
     } 
+0

Có phải trên thiên hà s2? – 0605002

Các vấn đề liên quan