I'm trying to start playing youtube video via youtube API. On most browsers it does work, but on Samsung Galaxy Tab 2 7.0' default browser it does not.
On most browsers the video starts playing automatically when the page loads.
On SGT7 it starts loading video, then black screen appears with some icon in the upper left corner that looks like a "film" or a "key". It does not respond to user input.
I tried installing Firefox on that device and it does work OK.
You can see the example here: http://ser5.ru/t/yt_api.php
The source code of this example is placed below. As you can see, I'm using embed code from API help: https://developers.google.com/youtube/iframe_api_reference
So, the question is: am I able to start youtube videos on that specific browser via API or should I use some other way?
<!doctype html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="player"></div>
<script>
(function () {
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
})();
function onYouTubeIframeAPIReady () {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': function () {player.playVideo()}
}
});
}
</script>
</body>
</html>
I noticed the same behavior on this device and others
player.playVideo() will not play the video, this seems to be intended by design as AutoPlay is not allowed on mobile devices to prevent unintended data charges.
You must cue the video and allow the user to invoke play
player.cueVideoById(videoId);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments