i am making a phonegap app which shows videos via an html5 video player. The video play fast and fine on ios, but it takes time to start playing on android. it loads some part of the video or maybe the whle video and then plays it. i have given the preload="none" attribute. how do i make the video play instantly?
Android will not preload the video on mobile web implementations. Also, even after the video has been preloaded (the first few bytes), the decoding takes some time on weak devices.
For this reason, your best bet IMHO would be:
Enable the autoplay without user gesture on the web view that contains your phonegap app
WebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
Then:
In JS, mute and hide the video, and star to play it
When the user performs the action that triggers the play, set the video's location to 0, reveal and umute it:
document.getElementById('myVideo').currentTime = 0;
document.getElementById('myVideo').muted = false;
Related
This question is basically the same as this one which has a solution for HLTML5 videos, except that changing the chrome://flags to set gesture requirement for media playback to disabled has no influence on a YouTube embedded player.
I have built a webapp I use to learn music, and loop specific parts of Youtube music videos to learn how to play the song. Here is an example. This works fine on a computer, but using Chrome (59) on Android (7.1.1) I have to tap the video each time it starts again to put the sound back on. Not handy when trying to use my hands to learn playing the music ;)
The code I'm using to embed the player and interact via Javascript can be found here.
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 would like to play a HTML5 video back to the user directly in the native android video player.
My current setup takes way too much effort to get into the native video player: Currently I have a WebView with an embedded HTML5 video (such as a Youtube or Vimeo HTML5, not flash, embed). The user has to hit play on the video, and then hit the fullscreen button (on far right in the picture below)
Then it opens in the native player which looks like this:
The native player is a View is a much better experience for video playback. (I believe it is a VideoView? though maybe it is different in newer versions of Android. It is a View within my Activity so provides extra control. See this post for more info.)
I'm looking for a graceful way of directly launching into this experience instead of having to load the embed in a WebView and then leaving it to the user to tap the full screen button.
Any ideas?
Thanks!
First some details to help explain:
If you load a Vimeo link such as the following:
http://player.vimeo.com/video/40234826, or use their iframe embed code,
into a WebView, one of two things will happen.
If the device has the Adobe Flash Player app/plugin installed, it will display Vimeo's embedded player. Tapping play, plays the video inline as an embed.
If the device does not have the flash plugin, it will display an image with a play button. Tapping play, opens the Video in a system VideoView. (Because the button links to an mp4 file.)
Since Vimeo's embedded play can be a bit buggy on the vast variety of devices available, I have found that option 2, playing the Vimeo video in an Android media player is a much better experience.
Now the question is, how can I convince the WebView not to use Flash?
I have tried webview.getSettings().setPluginsEnabled(false); but it still loads the flash embed version. How can I trick Vimeo's player into thinking the device does not have flash installed?
Thanks
Update
After further investigating, it seems that setPluginState(PluginState.OFF) works pre honeycomb, but this doesn't work on Honeycomb and ICS.
I'm developing a web page intended for use on mobile devices, primarily Pandigital tablets running Android. On this page I have an html5 video element that plays upon page load, and when the video ends I need to have a Javascript function trigger and hide the video element. So far I have a basic multipage document set up with jQuery mobile just to test whether I can even get a trigger to work. The function I'm using is:
pageInit(function(){
$("#vid1").bind('ended', function(){
$.mobile.changePage($('#two'), 'fade');
});
});
The video (with a proper id="vid1") pops into fullscreen and plays perfectly. However, the page doesn't change when the video is finished playing. I am testing using Android 2.3.4.