android 控制器,Android - 媒体控制器不显示

我有一个videoView,我在那里显示一个视频,我想显示默认的媒体控制器 . 出于某种原因,控制器似乎不想出现 .

我尝试使用xml创建MediaController,将其设置为始终可见,使用 mMediaController.setMediaPlayer(mVideoView) 将其附加到媒体播放器,但似乎没有任何效果 .

可能发生什么?听众是否会输掉比赛?是不是附加到实际的视频播放?我应该在我正在使用的代码中添加其他内容(见下文)吗?

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.activity_content_video);

[...]

mVideoView = (VideoView) findViewById(R.id.surface);

mainVideoHolder = (LinearLayout) findViewById(R.id.main_video_holder);

holder = mVideoView.getHolder();

holder.addCallback(this);

mMediaController = new MediaController(this);

mMediaController.show();

}

private void playVideo() {

doCleanUp();

try {

mMediaPlayer = new MediaPlayer();

Log.d(tag, "surfaceCreated");

File f = new File(mAssetsPath);

File[] files = f.listFiles();

Log.d(tag, "File: " + files[0].toString());

URI uri = URI.create("file://" + (files[0].toString()));

File file = new File(uri);

ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE);

mMediaPlayer.setDataSource(parcel.getFileDescriptor());

mMediaPlayer.setDisplay(holder);

mMediaPlayer.prepare();

mMediaPlayer.setOnBufferingUpdateListener(this);

mMediaPlayer.setOnCompletionListener(this);

mMediaPlayer.setOnPreparedListener(this);

mMediaPlayer.setOnVideoSizeChangedListener(this);

mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

mMediaController.setMediaPlayer(mVideoView);

mVideoView.setMediaController(mMediaController);

} catch (Exception e) {

Log.e(tag, "error: " + e.getMessage(), e);

}

}

public void surfaceCreated(SurfaceHolder holder) {

Log.d(tag, "surfaceCreated called");

playVideo();

}

任何想法将不胜感激?

活动中没有应用主题,视频正常播放而不会出现任何错误 . 只是媒体控制器没有显示出来!

谢谢 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值