Youtube movies in webview

marcel

Active Member
Licensed User
Longtime User
Hi,

I am still having troubles with youtube movies in the webview. I have used MyWebViewExtras to add the chromeclient. This solves at least that it is playing. But when I turn the device it hangs or plays in the background.

I saw on stackoverflow the same problems and they solved it:

YouTube Video not playing in WebView - Android - Stack Overflow

Is this possible with B4A?
 

warwound

Expert
Licensed User
Longtime User
Is it essential to play the videos in a WebView?

An alternative would be to use my YouTubeStreamFinder to find the url to a high quality You Tube video and then play that video using the VideoView.

That way you'd be free of all the various problems/bugs with different versions of WebView on different versions of Android.

Martin.
 
Upvote 0

marcel

Active Member
Licensed User
Longtime User
Is it essential to play the videos in a WebView?

An alternative would be to use my YouTubeStreamFinder to find the url to a high quality You Tube video and then play that video using the VideoView.

That way you'd be free of all the various problems/bugs with different versions of WebView on different versions of Android.

Yes, the yourtube video is part of a message that will be displayed. It's a requirement of my client. It works in iPhone also he said why not here :)
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
The Android WebView seems to be one of the more buggier Views that exist.
In different versions of the Android SDK it has different bugs and often unpredictable behavior.

The link in your first post suggests two possible solutions:

1) Add the android:hardwareAccelerated="true" attribute to your manifest file.

2) Create a WebChromeClient that implements onShowCustomView and onHideCustomView, and optionally also implements getDefaultVideoPoster and getVideoLoadingProgressView.
This would require a custom B4A library and i suspect is not guaranteed to work.

Another suggestion on that page is to set the WebView user-agent so that the You Tube website thinks you are connecting from a desktop browser rather than a mobile WebView.
You can try setting the user-agent with WebViewSettings, it'll be a quick fix if it works.

The manifest edit is also a quick fix to try.

Otherwise the custom WebChromeClient is possible but i think all that will do is to remove the video player from the WebView and allow you to insert it into a different container (such as a Panel).
If that is the case then you might as well use a VideoView.

Martin.
 
Upvote 0

marcel

Active Member
Licensed User
Longtime User
The Android WebView seems to be one of the more buggier Views that exist.
In different versions of the Android SDK it has different bugs and often unpredictable behavior.

It is really buggy. I didn't expext that from google.

1) Add the android:hardwareAccelerated="true" attribute to your manifest file.

I did try this one already without any success.


2) Create a WebChromeClient that implements onShowCustomView and onHideCustomView, and optionally also implements getDefaultVideoPoster and getVideoLoadingProgressView.
This would require a custom B4A library and i suspect is not guaranteed to work.

I really do not have any knowledge about this. So this is for me unfortunatly no option....

Another suggestion on that page is to set the WebView user-agent so that the You Tube website thinks you are connecting from a desktop browser rather than a mobile WebView.

I tried this one also, no luck. The video doesn't play at all and the screen widht of the page is suddenly that big that you only see 1/5th of the start screen :)

Anything else I might try?

When I add
B4X:
MyWebViewExtras.addWebChromeClient(WebView1, "MyEventName")

Than at least it is playing the video but I can not get it full screen and when I turn my device it hangs....:BangHead:
 
Upvote 0
Top