I am using routing with angular2, I have two routes (components) that each have an instance of a PlayerComponent, hosting a youtube Iframe and having a singleton PlayerService behind. If I have a video loaded in one component and I switch to a different route (same video, different component) the first playerComponent is destroyed and the 2nd component is loaded. The video ID is contained in the playerService. It works, but on the switch from the first playerComponent to the second playerComponent, the video automatically starts to play which I don't want. The embed url contains autoplay=0.
How can I stop this switch starting an autoplay?
Not a completely specific answer, but in my context I have the IFrame in my template with a binding to the embed url. I found that if I change the embedURL via the binding to my component, it works better than changing the videoId on the YT.Player.
Related
My app generates the first YouTube url below and embed it. I would like to start the playlist at a specific video. It is possible to do so on non-embed link with the parameter index (see 2nd link below) but this parameter does not work for my embed link.
https://www.youtube.com/embed/uNDfgnWN2G0?rel=0&enablejsapi=1&playlist=IJrwmIQqj5s,uNDfgnWN2G0,pDf46hYF4CE
https://www.youtube.com/watch_videos?video_ids=uNDfgnWN2G0,IJrwmIQqj5s,uNDfgnWN2G0,pDf46hYF4CE&index=2
Is there an alternative url parameter I could use?
I tried the parameter start as well but it doesn't work with my playlist link if I want to go beyond the second video.
https://developers.google.com/youtube/player_parameters
YouTube supports interactive-transcripts, using both machine-generated and user-uploaded transcripts. This is very useful for hearings, lectures, speeches, and educational videos where a visitor might want to read along or jump around. For example in this video:
https://www.youtube.com/watch?v=IY3U2GXhz44
The visitor can click on "...More" and then "Transcript" to view the interactive-transcript.
How does a video owner make that hidden feature automatically open for visitors? I cannot find any documented method for doing that through the API for either embed or linked videos. Is there an undocumented method in the API, or a URL parameter like "&action-panel-transcript=true" that works the way I'd expect it to?
As for url parameter, you can try adding &cc_load_policy=1 behind the rel=0 if it's an embedded video or &yt:cc=on at the end of the url if it's a link to the video.
Source: https://www.makeuseof.com/tag/force-subtitles-embedded-youtube-video/
We own the YouTube account we're trying to play content from, but playback within our iOS app using the YouTube Helper is being restricted: https://developers.google.com/youtube/v3/guides/ios_youtube_helper#best_practices
Is this perhaps because of the anonymity of the web view created by the helper?
Can I configure the helper or account differently to unblock the content? I guess I could serve a web view from a whitelisted host, essentially bypassing/re-writing the YouTube helper, but that would not be ideal - extra http request etc..
Thanks in advance
Here is my current understanding and work around.
The Problem
Any kind of access restriction on a channel (whitelist/blacklist etc.) requires that the parent of the iframe be served from a real host. The iOS YouTube Helper Library manually creates a webview into which the iframe is loaded, and so the channel block playback because it isn't possible to restrict playback within the parent (anonymous webview).
This is easily verified for a given channel by pasting an embed for a video from the channel into a simple local HTML page, and loading it into your browser. Playback will be blocked.
The Solution
So, we need a web page that uses the iFrame API served from a not-blacklisted/whitelisted (depending on your channel access control) host. I took the HTML template from the youtube helper library, and parameterized the URL to fill in the params to the template initialization:
new YT.Player('player', %#);
So now rather than loading data from a template HTML string in the helper, I now load a request:
[self.webView loadRequest:req];
The final gotcha is that the "handleHttpNavigationToUrl" condition in the following block was causing Safari to open on page load, so comment out or handle that better:
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
if ([request.URL.scheme isEqual:#"ytplayer"]) {
[self notifyDelegateOfYouTubeCallbackUrl:request.URL];
return NO;
} else if ([request.URL.scheme isEqual: #"http"] || [request.URL.scheme isEqual:#"https"]) {
return [self handleHttpNavigationToUrl:request.URL];
}
return YES;
}
The New Problem
This work around adds one more delay into the flow of loading a video for the user. The new HTTP request to serve the initial page joins the existing steps of:
Load YouTube iFrame API JS
Load iFrame of player
Begin stream of video initialized into player
All of this, rather than just initializing a native player with a stream URL. Not a great user experience for sure.
I plan on working around it by preloading the page, API and iframe ready for initialization with a video ID on user request.
Mine problem was that when I clicked on the play button it showed me an error. I was trying to load youtube video.
This video contains content from <..channelname..>. It is restricted from
playback on certain sites. Watch on YouTube.
The solution which I used was this
NSDictionary *playerVars = #{
#"origin" : #"http://www.youtube.com",
...any other variables
};
[self.playerView loadWithVideoId:videoId playerVars:playerVars];
simply add origin variable in the playerVar and you are good to go.
Hope this help someone.
Thanks
Yes, you are right. Helper library is basically a wrapper around the iFrame API. You could repurpose the helper, or use the iFrame API straight for your whitelisted host.
I want to show an MP3 player that the user can control while navigating the rails app. When they load new pages, the MP3 will continue playing. My first thought was to make every page load with AJAX, and have the MP3 player on the main page. So new content loads, but the MP3 player just stays in place.
Second thoughts: I would need to 'ajaxify' the whole rails app just to show the mp3 player. In addition, I suspect this is less search-engine friendly than a normal app. I would appreciate your opinions and options on this matter. Or isn't the SEO thing a problem? Thanks in advance for your help!
You can catch the changing url in JavaScript and modify the page content dynamically without actually reloading the page. A popular library function that handles this is Angular's routing capabilities.
This YouTube video can be embedded into most sites (e.g., Stackoverflow), but it cannot be embedded into Rap Genius. You can try it yourself by pasting the embed code in to Rap Genius with firebug. You'll see this:
I need a way to detect whether a video is specifically blocked from Rap Genius.
Note that this is different from checking whether a video cannot be embedded anywhere – i.e., if you GET http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=_kmeFXjjGfk, you'll see that in the JSON response, data.items[0].accessControl.embed == 'allowed'
One clue: before the video starts playing, the player makes a request to a URL that looks like this:
http://www.youtube.com/get_video_info?video_id=_kmeFXjjGfk&el=embedded&ps=default&eurl=http%3A%2F%2Frapgenius%2Ecom&hl=en_US
Which, when curled, gives this response:
status=fail&errorcode=150&reason=This+video+contains+content+from+UMG%2C+who+has+blocked+it+from+display+on+this+website.%3Cbr%2F%3E%3Cu%3E%3Ca+href%3D%27http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_kmeFXjjGfk%26feature%3Dplayer_embedded%27+target%3D%27_blank%27%3EWatch+on+YouTube%3C%2Fa%3E%3C%2Fu%3E&fslarge=1
So maybe I can just query this URL? Will this work in all cases? Is there an "official" way of doing this?
I had the error:
This video contains content from XXX
I noticed I was using https when requesting the page containing the embedded video. Switching back to http seems to have fixed the problem.
You have all the info in http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=_kmeFXjjGfk
"status":{"value":"restricted","reason":"limitedSyndication"},"restrictions":[{"type":"country","relationship":"deny","countries":"DE"}]
March 19, 2013 -- Response is now quite different than that given above:
{"apiVersion":"2.1","data":{"updated":"2013-03-19T14:47:14.533Z","totalItems":0,"startIndex":1,"itemsPerPage":25}}