android 媒体控制搜索栏问题

发布于 2024-12-17 21:59:07 字数 164 浏览 3 评论 0原文

在我的 Android 应用程序中,我遇到了用于 VideoviewMediaController 搜索栏的问题。
我想知道用户是否寻找大于缓冲位置的位置,我需要显示一个对话框,然后在搜索完成时关闭对话框。
如果我能解决这个问题,请告诉我。

In my Android application I am facing issue with seekbar of MediaController that I am using for Videoview.
I would like to know if the user seeks to a position greater than the buffered position,I need to show a dialog and then dismiss the dialogue on seek completed.
Please let me know if I can have this solved.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

緦唸λ蓇 2024-12-24 21:59:07
mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

   @Override
   public void onStopTrackingTouch(SeekBar arg0) {
         // you can check for the current buffer state and where the use seek using mSeekBar.getProgress() and then open up a dialog.

        if(condition to match buffering and seek position)
               openDialog();
   }

   @Override
   public void onStartTrackingTouch(SeekBar arg0) {

   }

   @Override
   public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) {

   }
  });

...

public void openDialog()
{
  ...
  // check for buffer level to match your seek position
  // when it meets the codition,cancel the dialog.
  ...
}
mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

   @Override
   public void onStopTrackingTouch(SeekBar arg0) {
         // you can check for the current buffer state and where the use seek using mSeekBar.getProgress() and then open up a dialog.

        if(condition to match buffering and seek position)
               openDialog();
   }

   @Override
   public void onStartTrackingTouch(SeekBar arg0) {

   }

   @Override
   public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) {

   }
  });

...

public void openDialog()
{
  ...
  // check for buffer level to match your seek position
  // when it meets the codition,cancel the dialog.
  ...
}
我的痛♀有谁懂 2024-12-24 21:59:07

有几种方法可以做到这一点。

选项 1: 只需使用媒体播放器中的 OnInfoListener。
当缓冲开始和停止时,这将向您发送信息。

mPlayer.setOnInfoListener(OnInfo);

然后创建您的侦听器代码。

// info from player sent.
OnInfoListener OnInfo = 
    new OnInfoListener() {
        public boolean onInfo(MediaPlayer mp, int what, int extra) {
            Log.d(TAG,"media info what:"+what+" extra:"+extra);

            // check about buffering status.
            if(what==MediaPlayer.MEDIA_INFO_BUFFERING_START) {
                // note: we are assuming _progressDialog was created already
                _progressDialog.setMessage("Buffering...");
                _progressDialog.show();
            } else if(what==MediaPlayer.MEDIA_INFO_BUFFERING_END) {
                if(_progressDialog.isShowing())
                    _progressDialog.dismiss();
            }
            return false;
        }
    };

选项 2:使用 OnBufferingUpdateListener 来跟踪已缓冲的量。

<代码>
mPlayer.setOnBufferingListener(OnBufferingUpdate);

然后创建实际的监听代码。

// buffering update
OnBufferingUpdateListener OnBufferingUpdate =
    new OnBufferingUpdateListener() {
        @Override
        public void onBufferingUpdate(MediaPlayer mp, int percent) {
                    Log.d(TAG,"BUFFERING: "+ String.valueOf(percent));
                    // store the percent value and check it in onStopTrackingTouch() 
                    // which is in your setOnSeekBarChangeListener
        }
    };

Couple ways of doing this.

Option 1: Just use the OnInfoListener from the media player.
This will send you info when the buffering has started and stopped.

mPlayer.setOnInfoListener(OnInfo);

Then create your listener code.

// info from player sent.
OnInfoListener OnInfo = 
    new OnInfoListener() {
        public boolean onInfo(MediaPlayer mp, int what, int extra) {
            Log.d(TAG,"media info what:"+what+" extra:"+extra);

            // check about buffering status.
            if(what==MediaPlayer.MEDIA_INFO_BUFFERING_START) {
                // note: we are assuming _progressDialog was created already
                _progressDialog.setMessage("Buffering...");
                _progressDialog.show();
            } else if(what==MediaPlayer.MEDIA_INFO_BUFFERING_END) {
                if(_progressDialog.isShowing())
                    _progressDialog.dismiss();
            }
            return false;
        }
    };

Option 2: use the OnBufferingUpdateListener to keep track of how much has been buffered.


mPlayer.setOnBufferingListener(OnBufferingUpdate);

Then create the actual listen code.

// buffering update
OnBufferingUpdateListener OnBufferingUpdate =
    new OnBufferingUpdateListener() {
        @Override
        public void onBufferingUpdate(MediaPlayer mp, int percent) {
                    Log.d(TAG,"BUFFERING: "+ String.valueOf(percent));
                    // store the percent value and check it in onStopTrackingTouch() 
                    // which is in your setOnSeekBarChangeListener
        }
    };
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文