Back button won't work when VideoView is playing video
Asked Answered
G

1

4

I have a VideoView in one of my Activities and if I try to press the back Button it doesn't take me to the previous Activity and it doesn't give any error messages in the log cat either.

I have tried overriding the onBackPressed() method and I have tried calling the prev Activity using an Intent, but even then the back Button didn't do anything.

This problem only occurs when the video is playing and even after it is finished playing. The only time the back Button works is before the video starts playing. My VideoView also has a MediaController set to it.

Any ideas ?

Thanks!

Guiana answered 2/8, 2012 at 14:33 Comment(1)
possible duplicate of Android back button and MediaControllerAnfractuous
A
4

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.

Anfractuous answered 2/8, 2012 at 14:41 Comment(1)
No problem. Be sure to go to that post i linked and vote it up. =)Anfractuous

© 2022 - 2024 — McMap. All rights reserved.