0

i created a webview for playing the html5 video. I find that on the 2.3.3(HTC), when i start playing the video, it automatically goto fullscreen mode, but on my nexus 4, it plays in embedded mode. I want it play in full-screen mode also in android 4.x, is there any hint?

Furthermore, I find several links about videos playing in fullscreen mode, such as Android Webview app won't let video player go full screen

Playing HTML5 video on fullscreen in android webview

But they seems the case it failed playing full-screen with "full screen" button, not the start playing button. After all, when press "full screen" button, the WebChromeClient's onShowCustomView is invoked, but how about the "play" button?

[------------------------------UPDATE--------------------------]

seems quite hard to achieve this. The only article seeming suitable for this is enter link description here

but I have not made it through till now..

Community
  • 1
  • 1
mianlaoshu
  • 2,342
  • 3
  • 27
  • 48
  • [Playing HTML5 video on fullscreen in android webview](http://stackoverflow.com/questions/15768837/playing-html5-video-on-fullscreen-in-android-webview) working fine to make video full screen and min screen on 4.1 devices. what happen when you are pressing Fullscreen button? – ρяσѕρєя K Nov 26 '13 at 05:20
  • on my nexus, when i press the fullscreen button, the onShowCustomView is invoked, then it will enter fullscreen mode. But when press Play button, onShowCustomView not invoked (according to the doc, onShowCustomView not for Play case). What i want is just when click Play button, then fullscreen.. – mianlaoshu Nov 26 '13 at 05:38

1 Answers1

0

the following JavaScript codes can play a video full screen:

video = document.getElementsByTagName("video")[0];
if (!document.webkitFullScreen && video.webkitEnterFullscreen) {
    video.webkitEnterFullscreen();    
}

but if it runs in play event listener of video element, INVALIED_STATE_EXCEPTION will be thrown out(because it should be triggered by user gesture). This can work in click event listener, so WevView.dispatchTouchEvent(MotionEvent) can trigger a click event to play video full screen automatically. It's a workaround resolution.