2014-06-24 63 views
0

我使用下面的代碼在仿真器和設備上進行測試,結果出來的是,仿真器可以在VideoView下方顯示MediaController(默認位於屏幕底部)。但是,當我在設備中測試時,它不顯示MediaController。 我想知道爲什麼。設備不顯示MediaController

final VideoView videoView = (VideoView)findViewById(R.id.videoGuide1); 

    videoView.setOnPreparedListener(new OnPreparedListener(){ 
     @Override 
     public void onPrepared(MediaPlayer mp){ 
      mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener(){ 
       @Override 
       public void onVideoSizeChanged(MediaPlayer mp, int width, int height){ 
        MediaController mediaController = new MediaController(WatchVideo.this);; 
        videoView.setMediaController(mediaController); 
        mediaController.setAnchorView(videoView); 
       } 
      }); 
     } 
    }); 
+0

檢查我的答案,試試這個 – Mahesh

回答

1

試試這個它爲我....

VideoView vv; 

     vv = (VideoView) findViewById(R.id.videoView); 
     vv.setVideoPath(filename); 
     vv.setMediaController(new MediaController(this)); 
     vv.requestFocus(); 
     vv.start(); 
    } 

}

0

嘗試這種方式

MediaController controller; 
Videoview videoview; 

videoview=(VideoView)findViewById(R.id.videoview); 
controller = new MediaController(this); 

videoview.setVideoURI(Uri.parse(path)); 
videoview.setMediaController(controller); 
controller.setMediaPlayer(videoview); 


videoview.setOnPreparedListener(new OnPreparedListener() { 

      public void onPrepared(MediaPlayer mp) { 
       int duration = videoview.getDuration(); 
       videoview.requestFocus(); 
       videoview.start(); 
       controller.show(); 

       Log.d("Video view is prepared","------>"); 

      } 
     });