0

I want to report Video position when user presses back button. Video is played inside a Custom View implementation which is a part of SDK. So i dont have access to Activity's backButtonPressed method.

I tried dispatchKeyEvent but it requires view to be focused. It shouldn't be necessary.

Custom View implements FrameLayout and adds an instance of VideoView if it is expected to play video.

Is there any way to catch backbutton presses inside such a Custom View?

Thanks All,

mehmet6parmak
  • 4,777
  • 16
  • 50
  • 71

1 Answers1

1

You could use the Window events like onWindowVisibilityChanged, onDetachedFromWindow, etc., to take care of the pausing and reporting video position. Take a look at the second example in the setSystemUiVisibility documentation.

Rajesh
  • 15,724
  • 7
  • 46
  • 95
  • Thank you for the response, i used onWindowsVisibilityChanged but in addition to this i extended VideoView and customized its onWindowVisibilityChanged method because onWindowsVisibilityChanged of VideoView runs before the VideoView's parent Views' onWindowsVisibilityChanged that is where i need to get stream position. I emptied onWindowVisibilityChanged method of VideoView and called it manually after getting position inside onWindowVisibilityChanged handler of parent view. It is complicated and is not nice but worked :) – mehmet6parmak Oct 17 '12 at 13:34