Hardware accelerated Android Webview crashes on multiple devices + HTML5 video issue - android

I'm using WebViews in my apps, and many users reported some issues. It appears that most of them seem to happen on 4.1.1, not before.
The configuration:
A Webview, inside a HW accelerated activity.
JS enabled, Plugins enabled, File access enabled, DOM storage enabled.
Custom WebChromeClient and WebViewClient.
Webview has a transparent background (0X00000000) but removing it seems to have no good improvement.
The problem:
Random black outs when showing some URLs: black out meaning, the activity just dies, there is no JAVA exception.
Usually, logs report a SIGSEGV, in glDrawArrays(), but could also be somewhere else (not enough information from users).
A workaround?
Simply disable the HW acceleration on the webview! Yeah, no more black out, that's right... But then (even if we consider this workaround is just so so, as the display performance decreases quite a lot):
A new problem:
Without HW acceleration, HTML5 videos (youtube) are not working: Sound starts, but video doesn't.
A solution could be to catch a playback starting event, to make the video play in a videoView, the same way we can do for fullscreen playback (using onShowCustomView, see Playing HTML5 video on fullscreen in android webview). Nevertheless, I'm currently not able to catch such an event. Please note that I'm not owner of the HTML pages, and the HTML code cannot be changed to append some kind of Javascript code in it.
Questions:
Does anyone has the same kind of crash, using HW acceleration + webview, on many devices? If so, how do you solve that?
About the workaround, deos anyone know how to solve this problem? Would be great to do like on IOS: clicking on the does not try to play the video inline, but instead it just opens the video application.
Thanks for reading!

Related

HTML5 video element does not restart a live stream at its live point if I pause it

As a viewer, I expect that if I pause a live stream, when I unpause it, it will restart from the latest live point.
Instead, on HTML5 video elements, the restart point is just where the stream left off - i.e. it's no longer live.
That's a problem for live streaming as what's more important to the viewer is to stay up to date with what's happening now rather than catch up on stuff he may have missed.
Please note that removing controls is not possible in iOS (so the issue will arise for a large number of mobile devices) and that HTML5 is a requirement (at least for my purposes) for any newer mobile devices on Android and iOS.
Has anyone cracked this problem?

SoundCloud HTML5 Widget API - Play Not Working in Chrome for Android

You can see the player live here:
www.stateofpsychosis.com/media/
The viewable player is a custom player. The default SC player has been shrunk down to a 1x1px iframe so it can't be seen without using the developer tools to make changes to the style.
This is only a problem on Chrome for Android
For some reason I can't get the API to actually play the music. The Previous/Next buttons work in the sense that they query and change the info, but they won't play the song either. It does however change the default SoundCloud widget play button to a pause button. It changes the track info. But it just won't actually make any noise. If I make the widget viewable and push anything in the default player (as opposed to the custom one), it seems to work though.
I too, am facing the same issue.
It seems that Chrome for Android restricts the ability to trigger HTML5 audio playing. This is to protect users from extra data usage on their phones. It seems that triggering the audio to play from a script is not allowed.
You can read more about the issue
here
Hopefully they lift this restriction in the near future.

workaround for onShowCustomView

I need to extract the Uri of the currently playing video inside the videoview embedded in a webview . I am able to get this working for android 2.1 to 2.3.7 using the solution provided here
Android get Video source path from VideoView.
Unfortunately this does not work in android 3.0 above as the onShowCustomView callback is NOT called in minimised mode .
This issue is also logged here
http://code.google.com/p/android/issues/detail?id=36020
Can anybody provide me any alternative workaround to get the videoview uri.
Ok After searching around for a bit (see answer https://stackoverflow.com/a/3866411/1135101) apparently there is a way to listen for video events via JNI. Now the thing is I am not sure how to write a JNI function that listens for a video event . Can anybody say if this is even possible and how to go about it.
Ok last ditch effort
according to this answer
Show HTML5 Video Fullscreen
onShowCustomView is called in fullscreen mode.
Now the issue is how do i force the video to play in full screen mode when i have no control over the site.
I believe WebViewClient.shouldInterceptRequest(android.webkit.WebView, java.lang.String) might help. You will need to filter out video urls and simply return null.

Playing hi-quality youtube videos seamlessly Is it possible at all on android?

I have googled and googled on this. I cannot seem to find a way of seamlessly playing video in high quality from youtube.
I have tried so far:
Using a webview with the following:
htmlstring.append("<iframe title='YouTube video player' class='youtube-player' type='text/html' width='590px' height='370px' src='http://www.youtube.com/embed/");
htmlstring.append(wYouTubeId+"?autoplay='1' frameborder='0' allowFullScreen='1'></iframe>");
htmlstring.append("</center></body></html>");
webView.loadData(htmlstring.toString(), "text/html", "utf-8");
This has been working fine, but not on android 4 for some reason (Note & S3 tested)
So i tried this object version:
htmlstring.append("<object width='480' height='330'><param name='movie' value='http://www.youtube.com/v/"+wYouTubeId+"?version=3&hl=pt_BR&rel=0'>");
htmlstring.append("</param><param name='allowFullScreen' value='true'></param>");
htmlstring.append("<param name='allowscriptaccess' value='always'></param>");
htmlstring.append("<embed src='http://www.youtube.com/v/"+wYouTubeId+"?version=3&hl=pt_BR&rel=0' ");
htmlstring.append("type='application/x-shockwave-flash' width='480' height='330' allowscriptaccess='always' allowfullscreen='true' /></object>");
webView.loadData(htmlstring.toString(), "text/html", "utf-8");
No joy there either. It just spins and then gives out a blue lego block. These methods work on Android 2.2 though.
Then i tried this:
mp.setDataSource("http://www.youtube.com/v/"+wYouTubeId);
mp.prepare();
mp.start();
I have also tried this with a direct rtsp link found in the channel feed but they are of way too low quality to be usable. How can i tell which version is the high quality one as I am seeing loads of them.
I have also tried doing it manually with a VideoView but i get the same problem.
Lots of people recommend using this:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(fileListItem.getLink())));
But that is not an option, unless there is a way to launch the youtube app in landscape seamlessly without text. (Our client does not want it).
It seems to me strange that Android is a google system, Youtube is a google system yet on iOS (even iOS6!) it seems that it was easy to implement the video.
Why is it so hard to play a "google" video on "google" android??
This will be the best approach when it's publicly released: https://developers.google.com/events/io/sessions/gooio2012/120/ (I can't share any specific dates regarding its availability).
In the meantime, using the embed will probably get you closest to what you want. What specifically was broken about it when you tried it? Could you file a bug with a description of the problem, including the video ids you tried to play back?

VideoView vs WebView for playing youtube videos

I'm developing an application in which I need to play YouTube videos, I tried using webView and videoView, and I searched around a lot, I actually found some solutions, but they seem not to fit into my application needs:
So I want to know in the first place, the best way (approach) to the issue of playing a YouTube video inside an app. Should I use WebView and try to make the video fit the view and extra, or should I try VideoView (which is a little bit more complicated I guess, cause to be able to play videos I have to get the actual .3gp from Youtube).
Well thanks for helping me find the best approach.
MeanWhile I have got another question: is there a way to make the webView take the whole screen (full screen) on landscape mode (when the phone becomes landscape)?
Using the WebView approach can cause problems on some devices. The VideoView approach will work well as long as you have a solid way to parse the correct url. In one of my applications we do this using regex and parsing through the html, so far it works fast and efficiently.

Categories

Resources