YouTube videos (using latest API) won't play on Chrome on Android? - youtube-api

I'm developing a site for a client and am stuck at this point, as both of us have been able to recreate this issue in Chrome on Android.
For whatever reason, when we load this page on Android in Chrome:
http://miso.gostppro.com
The video loader just keeps spinning and spinning and the video never plays.
And tapping it on it doesn't do anything either (doesn't start the play, doesn't open it in YouTube app, nothing).
It works just fine in other browsers (Firefox for Android loads it and plays it just fine), so I'm confused as to why this is happening.
What am I missing?
Is it some call in the API or something?
I'm lost.

In short, it won't work. Quoting the documentation:
The HTML5 element, in certain mobile browsers (such as Chrome
and Safari), only allows playback to take place if it's initiated by a
user interaction (such as tapping on the player). (...) Due to this
restriction, functions and parameters such as autoplay,
playVideo(), loadVideoById() won't work in all mobile environments.
You're calling event.target.playVideo(); in your onPlayerReady handler, which is not allowed in mobile environments and throws a warning in console (for future reference - I highly recommend using Remote Debugging in Chrome).
So, back to your problem - I'd just get rid of the onPlayerReady handler and use autoplay player variable instead. It should work on desktops and not break the player on mobile either.

I tested your webpage on my Nexus 5 running Android 5.1.1 and found a few issues:
First I was getting this error:
Failed to execute 'postMessage' on 'DOMWindow': https://www.youtube.com !== http://miso.gostppro.com
Which I thought was an http vs https error, but after I refreshed the page with error went away and I saw a new warning:
Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture.
As pointed out in jkondratowicz's answer, this is a byproduct of mobile browsers disallowing autoplay on HTML5 videos. The only think I can think of is remove any JavaScript related to the player and the autoplay parameter and allow the user to manually start video playback when they're ready.
I was also getting mixed results results with adding an listener to the page load event which calls play() on the iframe:
function callback () {
document.querySelector('ytplayer').play();
}
window.addEventListener("load", callback, false);

Related

CloudStorageTools::serve() audio not playing on iOS

I'm using GoogleCloudStorage::serve() to serve .mp3 files via a website on Google App Engine with an HTML5 audio tag. Everything was working fine, but after an update for iOS, these devices were unable to play the audio in any browser.
I'm not sure why the code stopped working. Everything else still works fine on Android and Windows in all browsers.
It doesn't relay on Javascript or auto play at all. It's just a simple audio tag with the source being provided by GoogleCloudStorage::serve(), which works everywhere except recently on iOS.
Any input would be appreciated.
This is a shot in the dark because I don't know anything about serving audio files on iOS, but in case it helps...
About the same time you posted this question, a friend asked me to help him with his website. The website previously played audio, but around the time of your question, the audio stopped working on Safari on OS X.
The existing audio player that was being used was Flash based. I switched his website to playing audio using HTML5 and then it worked fine.
So you may want to check if you are playing audio in iOS with a Flash player and change it to HTML5 if you can.
Do you rely on autoplay? iOS disables autoplay, you really have to
let the user touch a button, or something.
Quote from Apple's documentation:
In Safari on iOS (for all devices, including iPad), where the user may
be on a cellular network and be charged per data unit, preload and
autoplay are disabled. No data is loaded until the user initiates it.
This means the JavaScript play() and load() methods are also inactive
until the user initiates playback, unless the play() or load() method
is triggered by user action. In other words, a user-initiated Play
button works, but an onLoad="play()" event does not.
This plays the movie: <input type="button" value="Play"
onclick="document.myMovie.play()">
This does nothing on iOS: <body onload="document.myMovie.play()">

Issues with Soundcloud iframe and YouTube iframe together

The Soundcloud widget works fine playing multiple tracks in succession. If I then hide that frame, play a youtube video in a youtube iframe, and then switch back to a new track in the Soundcloud widget, it loads but will not play (ignoring the autoplay setting and any widget.play() calls). I had this working on Chromecast with the developer preview SDK and the 1.0 cast receiver but now with the 2.0.0 receiver it's broken. Any ideas how to proceed?
Currently there is no supported mechanism in the SDK to play YouTube videos outside of the YouTube app. Note that in general, applications may not allow other senders launch or control their receiver side, for example Hulu+ may not like it if you wan to write your own app to launch and control that application on your Chromecast; if they decide to allow such model, they need to publish the steps (for example, they can publish their App ID and additional custom data that would link deep into their application). YouTube is no different in that respect.
ok, got this working so hopefully this is useful to others. Assuming only one is active and visible at a time, the trick is to destroy the prior widgets rather than try to reuse them. For YouTube this does not mean reloading the iframe_api but simply calling YTPlayer.destroy() and new YT.Player() next time around. For SoundCloud keep a handle of the iframe and then call iframe.parentNode.removeChild(iframe) to destroy and then create again next time.

Skype Video Call URI

I am working on a simple app that initiates Skype calls.
It successfully initiates Skype audio call using apple's URI scheme
[NSURL URLWithString:#"skype:skype_id?call"]).
But when I try to make a video call using
[NSURL URLWithString:#"skype:skype_id?call&video=true"]
it still initiates audio call and launches Skype but nothing happens after that (no audio call or video call is made). I have seen some posts where people mentioned that they used similar URI for making video calls for Skype in iOS that worked fine before but now it doesn't work.
I should mention that Android version of the app our team is working on have no such issue. It successfully starts making video call using same URI.
Is this a problem of latest version of skype developed for iOS?
this seems to be totally bust in skype for iOS.
even skype://username?call comes up with a fairly unintuitive modal saying "Placing call with..." which does NOTHING unless you click "Voice Call"
All works fine in other systmes / browsers (windows, mac osx, android), though https is bust in chrome. which is just dandy.
maybe https://stackoverflow.com/users/1383154/allen-smith or someone from skypes side can comment??
according to http://handleopenurl.com/scheme/skype you can use skype://username?chat in an html link. Now that sort of works - as in it opens skype, but still doesnt initiate the call.
You can't use the &video=true - IOS doesn't like it. Just use the ?call and it will work the same way it should (as if you appended the &video=true to it) and place a video call if video is available.
The skype stuff is pretty flaky - and my only success has been to use the skype buttons (using the skype-uri.js file and associated javascript for creating the buttons under HTTP (NOT HTTPS). HTTPS tends to break things in Chrome, and a few others.
What I did was sniff for IOS and remove the video=true accordingly so it works fine for all the other browsers too. End of the day, Skype really needs to clean up their act.

YouTube iframe API seekTo does not work on iOS 6 / iPad 3

See http://jsfiddle.net/rCGSB/4/.
Using the seekTo method from the YouTube iframe api does not work in mobile Safari under iOS 6 using an iPad 3.
The video just starts playing at the beginning. Once the video is playing, the seekTo method works. However, as stated in https://developers.google.com/youtube/iframe_api_reference#Playback_controls for the seekTo method:
"Seeks to a specified time in the video. If the player is paused when the function is called, it will remain paused. If the function is called from another state (playing, video cued, etc.), the player will play the video."
So, the video should start playing at the specified time even if it's not playing. And since I am interacting with a click, the disabled autoplay under mobile Safari should not be the problem.
It works fine on all desktop browsers I tested (FF, Safari, Chrome under Mac OS).
Does this work at all under iOS? Feel free to edit and update the fiddle.
Being able to playback from a certain point in time in a YouTube video is something I've been interested in for a long time.
I've found that this bit of iframe-based markup works, at least on iOS 6:
<iframe width="480" height="270" src="http://www.youtube.com/embed/n1-OKPmQyh4?fs=1&feature=oembed&start=533" frameborder="0" allowfullscreen="1"></iframe>
The trick is the "start" parameter in the URL you're using for the iframe
I've also wanted the "autoplay" parameter to work, but from my understanding Apple prevents that from happening so as to avoid excess data charges for users viewing web content.

jQuery mobile & HTML5 audio

I am working with jQuery mobile and using the HTML5 audio tag. I have a single button to trigger the playing of the audio on the page. I trigger the audio playback with the following:
$('#voice').live("click", function() {
$('#speech').trigger("play");
});
The audio tag is simple:
<audio src="path_to_media" id="speech"></audio>
When a page is first loaded the audio works perfectly however the audio tag and source on not updated on page transition, so going to another page with different audio and clicking play will play the same audio file as the first page unless of course I manually refresh the browser. Is there any way around this?
Can't specify your problem exactly however I've done exactly the same thing here: http://blog.colourbomb.net/?p=193
It performs fine on Desktop and iPhone but on Android I see the same behaviour you have, one solution is to delete the audio tag from the DOM, then create a new one and inject it giving you a new instance of an audio object that should be reset. Which platform are you seeing the issue on, do you get it happening in a desktop browser too?

Resources