I have a little app for our Kids Youtube channel what have a built-in Video Player and some games for kids.
I used to use VideoJs with a dedicated website what provides HTML player for all my Playlists, and streamed videos from CDN.
As it was too hard to re-encode and upload all our Youtube videos to the own CDN, I switched back to Youtube Iframe API, what is simply displays the official Playlists from our Youtube channel.
My player URL in app WebView: "https://v.kerekmese.hu/"
Thanks to the Iframe APIs "rel=0" parameter (used to disable related videos, but deprecated), the player on pause shows related videos only from our channel what is Ok, cause our goal is to keep user watch only our videos.
My problem is when I test with Debug APK in Android device, and click on the displayed related video it starts YouTube Player Website inside the current WebView, example:
"https://www.youtube.com/watch?v=S8gWfX0GKvQ"
That makes me alot of problems:
- its not the same iframe embed, so the UI is different
- mutes the video
- displays a big Open Youtube App link
- the page has scrolling what is ugly
- displays a lot of related videos from other channels :(
I've searched for solutions for days now, and found, that I should Handle Navigation by setWebViewClient():
developer.android.com/develop/ui/views/layout/webapps/webview
Also found shouldOverrideUrlLoading, what should catch URLs before loading:
developer.android.com/reference/android/webkit/WebViewClient.html
I have 2 ideas to handle this:
Better solution:
- listen to clicks what's matches: "https://www.youtube.com/watch?v=videoID"
- get the videoID variable from URL
- open custom URL inside my Webview: "https://v.kerekmese.hu/videoID" (the same iframe embed made by my own site's html)
Acceptable solution:
- listen to clicks what's matches: "https://www.youtube.com/watch?v=videoID"
- do nothing: do not open this, just wait for user to resume video play
But I know nothing about Andriod Studio, only using C3 and C3 export/build service for this little project.
Is it possible to handle link clicks inside C3/Webview?
Or will I need to do all the coding and build in Android Studio?
Just finished all the hard work to finally update our app, so many thanks for you kind of help in ancipation.