2013-04-30 50 views
0

我有一個很奇怪的問題。我正在使用蒸汽視頻,並在應用中播放,但問題在於音頻可以工作,但視頻無法正常工作。它顯示黑屏(請參閱圖像以供參考。)我不知道問題是什麼。音頻工作正常,但視頻顯示黑屏。VideoView Streaming:Audio works,but video is black

任何想法可以是什麼問題?

這裏是我的代碼以供參考:

public class Video_Low_Mission extends Activity { 
    // Put in your Video URL here 
    private String VideoURL = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov"; 
    // Declare some variables 
    private ProgressDialog pDialog; 
    VideoView videoview; 



@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    // Set the layout from video_main.xml 
    setContentView(R.layout.activity_video__low__mission); 
    // Find your VideoView in your video_main.xml layout 
    videoview = (VideoView) findViewById(R.id.VideoView); 
    // Execute StreamVideo AsyncTask 
    new StreamVideo().execute(); 

} 


// StreamVideo AsyncTask 
private class StreamVideo extends AsyncTask<Void, Void, Void> { 
    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
     // Create a progressbar 
     pDialog = new ProgressDialog(Video_Low_Mission.this); 
     // Set progressbar title 
     pDialog.setTitle("Mission TV (Low Quality)"); 
     // Set progressbar message 
     pDialog.setMessage("Buffering..."); 
     pDialog.setIndeterminate(false); 
     // Show progressbar 
     pDialog.show(); 

    } 

    @Override 
    protected Void doInBackground(Void... params) { 
     // TODO Auto-generated method stub 
     return null; 
    } 

    @Override 
    protected void onPostExecute(Void args) { 

     try { 
      // Start the MediaController 
      MediaController mediacontroller = new MediaController(
        Video_Low_Mission.this); 
      mediacontroller.setAnchorView(videoview); 
      // Get the URL from String VideoURL 
      Uri video = Uri.parse(VideoURL); 
      videoview.setMediaController(mediacontroller); 
      videoview.setVideoURI(video); 

      videoview.requestFocus(); 
      videoview.setOnPreparedListener(new OnPreparedListener() { 
       // Close the progress bar and play the video 
       public void onPrepared(MediaPlayer mp) { 
        pDialog.dismiss(); 
        videoview.start(); 
       } 
      }); 
     } catch (Exception e) { 
      pDialog.dismiss(); 

      // Error Here 

      Log.e("Error", e.getMessage()); 
      e.printStackTrace(); 
     } 

    } 

} 

// Not using options menu for this tutorial 
@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    getMenuInflater().inflate(R.menu.video__low__mission, menu); 
    return true; 
} 

XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <VideoView 
     android:id="@+id/VideoView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" /> 

</RelativeLayout> 

謝謝:)不支持對Android

回答

0

的MOV文件播放。 mov是一種蘋果格式,在android中沒有默認的視頻編解碼器來播放它們。 Reference

+0

謝謝。我想這是我的問題。將流轉換爲文檔格式。 :) – 2013-04-30 11:53:33

0

你可以試試vitamio框架,它支持.mov格式。請檢查此decription

+0

謝謝,但我該如何安裝它?對不起,我是新來的Eclipse和Android開發:) – 2013-04-30 11:54:17

0

我用下面的代碼解決了這個問題,我希望它適合你。

videoView.setBackgroundColor(Color.TRANSPARENT); 
相關問題