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.
Related
Impossible to autoplay youtube videos in an Android webview by using youtube iframe API. Does someone knows if that is possible?
As already mentioned in Mobile Considerations, functions and parameters such as autoplay, playVideo(), loadVideoById() won't work in all mobile environments due to the restrictions wherein HTML5 <video> element only allows playback to take place if it's initiated by a user interaction.
You may, however, try the given suggestions in the following SO posts and might work for you:
Youtube Api android autostart
You can use loadVideo() method which loads and plays the specified video. And, there is also the cueVideo() method, which adds the video to the playlist, but does not automatically start playing the video.
Android webview html5 video autoplay not working on android 4.0.3
You can usually work around it by triggering the play() on another event (eg the onloaded event).
Hope that helps!
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!
I am playing youtube videos in webview .In my app i have overridden the ontouch of webview. SO when user clicks on webview playing video, it opens another webview which is full screen . Now here the video is starting from the beginning. Instead of that is there a way to get the current postion of the video and to start playing from that point in the new webview.
ie i am looking for something equivalent to getCurrentposition and seekto in a videoview.
Please let me know if this is possible or is there any work around.
Thank you
I have done this before and I warn you that things might get messy in future!
Anyways, take a look at "JavaScriptInterface" for webview in android. here is a link
Also take a look at google's youtube player
There is Android youtube player as well as players using javascript/iframe etc.
I need to play a video with fullscreen when a user plays it.
Unfortunately, as far as I understand, if the HTML5 Video tag is used, Android plays it in-frame. So that tried webkitEnterFullScreen() and it seems to work(kind of...) but user has to click the play button again. Overall performance feels a bit clumsy and not sure if old OS like 2.0+ could handle it.
As an alternative method, I'm now trying to play video using direct link rather than the Video tag. For example, [a href="video.mp4"]Click to play[/a]. I think that it works well but the only problem is that it asks to choose a application either 'Video Player' or 'Browser'.
So my question is
How can I define using javascript to play the video using Video Player, so that the selection dialog won't prompt?.
What is the native video player for Android? For example, iOS uses Quicktime and it is possible to embed video using Quicktime object. And are there any equivalent method for Android?
When the Video tag is used, how to play video simultaneously with fullscreen?
try following code :
String path1="/path/to/video/file.3gp";
Uri uri=Uri.parse(path1);
VideoView video=(VideoView)findViewById(R.id.VideoView01);
video.setVideoURI(uri);
video.start();
You have to realize something very important: There is no native video player for android.
There is a dozens players for android and it is not your decision but the users decision if he should use player A or B. Don't try to force Android users to iOS behavior, it really doesn't give a better impression.
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.