Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seeking forward in YouTube HTML5 video over Android WebView

EDIT Nevermind, YouTube released the Native Android API (https://developers.google.com/youtube/android/player/)

I have an application that shows an HTML5 videoview over a WebView. This video is forced to be HTML5 from YouTube service (http://www.youtube.com/embed/3FFyT039tJ0?autoplay=1&rel=0&showinfo=0&html5=1&start=90&end=176 )

As you can see in the URL, the parameter "start" shows the number of seconds the video must start playing at. I have been using the method onShowCustomView of WebChromeClient to obtain the VideoView object created by the WebView, as seen here.

When I have the reference to the VideoView, I can use the method seekTo() to accomplish my goal. Till here everything is fine, but only for Android versions lower than 4.x.

As many of you know, the method onShowCustomView of WebViewChromeClient, from 4.x and forward, is only called when user clicks on "FullScreen" mode, but not when the video starts playing (how used to be before 4.x).

So, the point is that I can't seek 90 seconds forward because I can't obtain the reference to the VideoView, and I can't find any workaround.

like image 229
manelizzard Avatar asked Oct 21 '12 18:10

manelizzard


1 Answers

For future viewers

YouTube now has a player API: https://developers.google.com/youtube/android/player/

Where you can easily place a view in the xml and handle it in activity, here are the examples: https://github.com/youtube/yt-android-player

like image 151
Brandon Zamudio Avatar answered Oct 17 '22 23:10

Brandon Zamudio