Android的后退按钮和MediaController [英] Android back button and MediaController

查看:645
本文介绍了Android的后退按钮和MediaController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何利用后退按钮的控制权。我有一个 VideoView 嵌入在的FrameLayout 。我的问题是当视频弹出,视频控件是present几秒钟。点击Back按钮,而他们看到隐藏的视频控件。有没有办法忽略的功能,做下一个动作后面,如果视频控件不可见?

I know how to take control of the back button. I have a VideoView embedded in a FrameLayout. My question is when the video pops up, the video controls are present for a few seconds. Hitting the back button while they are visible hides the video controls. Is there a way to ignore that function and do the next back action as if the video controls weren't visible?

我想问的原因是,如果我真的想回去,我必须打的返回按钮两次;一旦隐藏控件和第二实际回去

The reason I ask is if I really do want to go back, I must hit the back button twice; once to hide the controls and second to actually go back

推荐答案

根据源$ C ​​$ C,这应该工作:

Based on the source code, this should work:

  1. 扩展的MediaController (对于这个答案的目的,把它叫做 RonnieMediaController
  2. 覆盖 dispatchKeyEvent() RonnieMediaController
  3. 在链接到超,检查 KeyEvent.KEY code_BACK ,并且如果遇到,告诉你的活动完成( )
  4. 使用 RonnieMediaController ,而不是的MediaController 与你的 VideoView
  1. Extend MediaController (for the purposes of this answer, call it RonnieMediaController)
  2. Override dispatchKeyEvent() in RonnieMediaController
  3. Before chaining to the superclass, check for KeyEvent.KEYCODE_BACK, and if that is encountered, tell your activity to finish()
  4. Use RonnieMediaController instead of MediaController with your VideoView

就个人而言,我只希望息事宁人,与此更改用户不能使 RonnieMediaController 消失的需求。

Personally, I'd just leave it alone, as with this change your user cannot make a RonnieMediaController disappear on demand.

这篇关于Android的后退按钮和MediaController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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