MediaController doesn't work

前端 未结 3 549
小蘑菇
小蘑菇 2021-01-23 02:52

My layout that contains videoView

 

        
3条回答
  •  温柔的废话
    2021-01-23 03:21

    
    

    Java

    // Get VideoView in layout xml
    VideoView mVideoView = (VideoView) findViewById(R.id.videoView);
    
    // MediaController provide controller, contains the buttons
    // like "Play/Pause", "Rewind", "Fast Forward" and a progress slide
    MediaController mediaController = new MediaController(this);
    
    mediaController.setAnchorView(mVideoView);
    mVideoView.setMediaController(mediaController);
    
    mVideoView.setVideoPath("/path/to/your/videofile");
    mVideoView.requestFocus();
    mVideoView.setOnPreparedListener(new OnPreparedListener() {
     public void onPrepared(MediaPlayer mp) {
      mVideoView.start();
     }
    });
    

提交回复
热议问题