Can anyone help me on how to make my embedded video in Ionic framework to autoplay when it loads.
example: I have a videos button then when I click it, it will go directly to the video then autoplay it
thanks in advance
I think if you use replace "&" with "?" in the url the video will autoload.
So your url would be: http://www.youtube.com/embed/qPMIQobB3ZM?autoplay=1
Seems like Google should have made this available, but I would say using a "?" makes more sense than using the "&".
In iOS HTML a video only starts on user input. You can't control this behaviour in ios Safari. Because you mention 'Ionic Framework' I assume you're building a app with Cordova / PhoneGape / Ionic builder? You could set <preference name="MediaPlaybackRequiresUserAction" value="true"/>
to the config.xml file http://cordova.apache.org/docs/en/4.0.0/guide_platforms_ios_config.md.html
Embed the player with:
<div id="ytplayer"></div>
<script>
// Load the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Replace the 'ytplayer' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
autoplay : 1
});
}
</script>