Problem with back button in VideoView

后端 未结 5 570
感动是毒
感动是毒 2021-01-05 08:03

I am having difficulty getting the back button to actually finish my activity when pressed. I am running a very simple videoview, using a progressdialog to show loading dial

5条回答
  •  我在风中等你
    2021-01-05 08:32

    From CommansWare

    Based on the source code, this should work:

    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

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

    Here is the link to the original post.

提交回复
热议问题