Search code examples
androidcordovahtml5-videoandroid-fullscreen

Exit full screen HTML5 video player using Android back utton in Phonegap Application


I am having a requirement where I am playing the videos in HTML5 video tag and when in full screen user cant able to back to the application as I have disabled the back button of android how to enable it only for this specific feature and redirect it to a particular page.


Solution

  • You can try it like this: override the onKeyDown function and check if you are playing a video, if so it loads a particular page else it does nothing.

    Private boolean videoPlayer = false;        
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)  {
        if(keyCode == KeyEvent.KEYCODE_BACK && videoPlayer)
        {
            //load particulair page
        }
        return true;
    }