cordova - youtube embedfailed to execute request fullscreen - cordova

I have created cordova android application in which some youtube video is embeded but on clicking youtube fullscreen button i am getting this error in
console log:
youtube embedFailed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
The iframe code is
<iframe class="embed_video" src="https://www.youtube.com/watch?v=XHJbEbq8zKQ" frameborder="0" allowfullscreen></iframe>
so how can i fix it.

Related

Electron webview doesn't auto-play youtube videos

Electron webview doesn't auto-play youtube videos. I am using Electron version 4.0.4
I send autoplay=1 as mentioned in Youtube docs, but no luck.
In the same time, Youtube URL auto-plays just fine in incognito Chrome window when copy/pasted.
Here is the simple code of webview
<webview id="youtube" src="https://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1"></webview>
Any help will be greatly appreciated!

Youtube iframe API - Android fullscreen

I'm using the YouTube iframe api to embed a video.
When playing the video on an iPhone, the video automatically switches to full screen mode. I was wondering if it's possible to force the same behavior on an Android? (currently the video is played inline, which doesn't look so good).
There is no way to automatically play the video fullscreen. The closest you could get is to put the player in a fullscreen div and autoplay it using the url params:
<iframe width="100%" height="100%" src="//www.youtube.com/embed/fSy6uh-GjCc?controls=0&autoplay=1&showinfo=0" frameborder="0" allowfullscreen></iframe>

Playing YouTube videos from embedded player

I am trying to play YouTube videos from a chrome extension and I get error code 150 frequently, specifically from videos that are from outside my country. I use Youtube Data API v3 to retrieve videos with the following parameters:
part=id&type=video&order=relevance&safeSearch=strict&videoSyndicated=true&maxResults=1&videoEmbeddable=true
However, I often get videos that throw error code 150 when played from my embedded player.
One example is the following video:
Turn down for what
when played from an embedded player, it throws error 150, and the error message shown in the iframe is
the video contains content from SME. It is restricted from playback on certain sites.
I try the same video with the same embedded iframe player in youtube Player demo website hosted on developers.google.com, and it plays without the error code.
Therefore, I suspect the above error happens because I am trying to play the video from chrome extension, not because I am playing it from an embedded player. When I play it from the webpage hosted on my local machine (ex: file:///home/testing.page.html), I get the same error message.
To resolve the issue, I attempted to make YouTube think that I was a normal webpage instead of a chrome extension. By using chrome.webRequest, I added a referer information to the request header.
{ name: 'Referer', value: "https://www.youtube.com" }
Even after the requestHeader was fixed, the error remained. I assume it's because there's origin property attached to youtube iframe player that specifies where the embedded player is from, regardless of the requestHeader.
My objective is either to find videos that are absolutely playable, or play videos that are only playable from a webpage (can't be played from chrome extension).
I would appreciate any help. Thank you.
Extra information
My iframe is initialized like below:
<iframe id="myframe" src="https://www.youtube.com/embed/?
enablejsapi=1&origin=chrome-extension:\\<my_extension_id>" frameborder="0" allowFullScreen></iframe>

Youtube redirecting http to https and using flash player instead of HTML5

I am using the youtube embed to show videos. Using IE11 (also FF28 but not FF27), when I am logged into my google account, the http request gets redirected to https, which isn't a big deal, except that even though I am specifying the html5 player, youtube serves up the flash player.
Is there some way to force http or force the html5 player over https?
Re-create:
Log in to google account and navigate to url "http://www.youtube.com/embed/u1zgFlCw8Aw?autoplay=1&html5=1"
redirects to https and flash player
Log out of google account and navigate to url "http://www.youtube.com/embed/u1zgFlCw8Aw?autoplay=1&html5=1"
Stays http and gets html5 player
Thanks in advance!
If you put the video in a sandboxed iframe and don't specifically allow plugins it can't load flashplayer, and thus has to use the html5 player. Note you have to at a minimum allow-same-origin, and allow-scripts or playback doesn't work. If you want the youtube button to be able to open the youtube page for the video you will also need allow-popups. Note that in the new window created from the youtube button the sandbox is still in effect even if navigated elsewhere manually by typing in a new URL.
<iframe seamless="" height="100%" width="100%"
sandbox="allow-same-origin allow-scripts"
src="http://www.youtube.com/embed/u1zgFlCw8Aw?autoplay=1">
</iframe>

iOS app playing youtube Video on Apple-TV

I would like to build an iOS app that plays youtube videos within a UIWebView window, with the UIWebView window being user selected to either play directly on the iOS device, or via AirPlay onto an AppleTV.
The website displayed in the UIWebView is my own website and will have javascript that will signal back-and-forth to the app when the youtube video ends (using the iframe api for youtube).
Question: Is the above possible?
Specifically, the iOS docs show that I need to have in the html within the UIWebView:
<video src="myPlaylist.m3u8"
height="300" width="400"
x-webkit-airplay="allow" >
<embed airplay="allow"
src="movie.mov"
width=400
height=300
mime-type="video/quicktime">
</embed>
</video>
But with YouTube iFrame api I do not have access to the < video > tag so how do I make the AirPlay icon visible to the user on the UIWebView window?
Thank you for any direction anyone can provide.
Jim
UIWebView uses it's own movie player controller to play embedded videos. It offers a setting to allow AirPlay:
[_webView setMediaPlaybackAllowsAirPlay:YES];
When set to YES, you'll get the familiar AirPlay icon when the movie plays.

Resources