安卓的MediaController播放暂停控制不正确刷新 [英] Android mediacontroller Play Pause controls not refresh properly

查看:579
本文介绍了安卓的MediaController播放暂停控制不正确刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在活动中使用的MediaController其工作正常,但是当我播放视频的第一次那么就应该有b暂停按钮可见,但取而代之的是戏,当我preSS该按钮则视频被正确和国有暂停保持不变,之后其正常工作。而同样的事情发生时,视频完成。 这是一个错误或我做任何事情错了吗?

  videoView.setOn preparedListener(新在preparedListener(){
    @覆盖
    公共无效于prepared(MediaPlayer的MP){
            的MediaController =新的MediaController(VideoPlayerActivity.this){
        公共无效隐藏(){
        }
        公共无效展(){
            如果(isPlayingAd){
                super.hide();
            }其他{
                super.show();
            }
        }
    };
    videoView.setMediaController(的MediaController);
    mediaController.setMediaPlayer(videoView);
    mediaController.show();
    }
});
 

解决方案

我一直有同样的问题。我没有叫 MediaController.setVideoView 为你,因为我以为 VideoView.setMediaController 足以接线的事情了。我想补充说,然后移动呼叫显示上ppared $ P $,现在它正在工作。

我希望我有更好的理解;我最好的猜测是,也许一切都需要进行接线正确地在媒体面前为prepared,以前叫秀。在任何情况下,这里是我有:

  mMediaController =新的MediaController(VideoPlayerActivity.this,假);

        mVideoView.setOn preparedListener(新MediaPlayer.On preparedListener(){

            @覆盖
            在prepared公共无效(MediaPlayer的PMP){
                mMediaController.show();
            }

        });

        mVideoView.setMediaController(mMediaController);
        mMediaController.setMediaPlayer(mVideoView);
        mVideoView.setVideoPath(URI); //可能不适用你的情况
        mVideoView.requestFocus();
        mVideoView.start();
 

I have used MediaController in my activity its working fine but when I play video for first time then there should b pause button visible but instead there is play and when I press that button then the video is paused correctly and state remains the same and after that its working properly. And same thing happens when Video Completed. Is this a bug or I am doing any thing wrong?

videoView.setOnPreparedListener(new OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
            mediaController = new MediaController(VideoPlayerActivity.this){
        public void hide(){
        }
        public void show(){
            if(isPlayingAd){
                super.hide();
            }else{
                super.show();
            }
        }
    };
    videoView.setMediaController(mediaController);
    mediaController.setMediaPlayer(videoView);
    mediaController.show();
    }
});

解决方案

I've been having the same issue. I was not calling MediaController.setVideoView as you were, as I thought VideoView.setMediaController was sufficient for wiring things up. I tried adding that, then moving the call to show within onPrepared, and now it is working.

I wish I had a better understanding; my best guess is that perhaps everything needs to be wired up properly before the media is prepared, and before calling show. In any case, here is what I have:

mMediaController = new MediaController(VideoPlayerActivity.this, false);

        mVideoView.setOnPreparedListener( new MediaPlayer.OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer pMp) {
                mMediaController.show();
            }

        });

        mVideoView.setMediaController(mMediaController);
        mMediaController.setMediaPlayer(mVideoView);
        mVideoView.setVideoPath(uri);  // may not be applicable in your case
        mVideoView.requestFocus();
        mVideoView.start();

这篇关于安卓的MediaController播放暂停控制不正确刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆