youtube and other video links not played in chromcast ios app - ios

I am working on an ios app where I need to play youtube and other websites's video in app as well as need to cast it on chromcast. I have followed Google's official code example from here https://codelabs.developers.google.com/codelabs/cast-videos-ios/#0 I am able to play several video links which has extensions like .mp4 but not able to play youtube video url.
working url :-
http://www.html5videoplayer.net/videos/toystory.mp4
but can't play youtube link like this
https://www.youtube.com/watch?v=WfV-0Yv5vNY
I am passing video link and other data in bellow code when user tap on play button while the chromcast it connected.
GCKMediaInformation *mediaInformation =
[[GCKMediaInformation alloc] initWithContentID:
#"https://www.youtube.com/watch?v=KgNSAXGVY8A"
streamType:GCKMediaStreamTypeNone
contentType:#""
metadata:metadata
streamDuration:0
customData:nil];
[_mediaControlChannel loadMedia:mediaInformation autoplay:YES playPosition:0];
My chromcast receiver type is default and I am using this key "kGCKMediaDefaultReceiverApplicationID" for casting on default receiver.
I have searched so may question for this issue but almost all the questions are related to android application.
so can anybody tell me whats is wrong with this? also I want to know that should I need to use custom receiver for youtube video player or I can use default one.
any help will be appreciate.

You cannot use the YT urls, like the one you have mentioned, in a default receiver for casting purposes. If you insist on playing YT videos in your own receiver, you'd need to write a custom receiver and embed a YT player in your receiver and handle communication with your receiver yourself. There are also limitations to this solution; for example you cannot skip ads, etc.

Related

Youtube ios player helper can't play video

I am using this library https://github.com/youtube/youtube-ios-player-helper
in my project. The player works well if I use the video Id given by the sample (M7lc1UVf-VE). If I use the video Id from r random video on youtube it shows:
An error occurred, please try again later. Learn More
Do I need to enable a youtube data API or something like that???
cause I see another IOS Youtube helper needs to do so.
https://github.com/youtube/yt-direct-lite-iOS
Thanks.
add this in your playerVars #"origin" :#"http://www.youtube.com" it will work.
If you only want to play youtube video, no API access is needed.
I work on with this library without any error, did you replace "M7lc1UVf-VE" with the correct video id?

YouTube embed AirPlay UIWebView

I am developing a video application which contains a lot of video from different sources. One of the options in the application has to be to play videos through airplay on a TV.
For displaying YouTube video in my application I am using YTPlayerView, which is an objective-C helper for the YouTube API.
My question is: is there an option or param I can pass so the YouTube video can also be played through Airplay? I couldn't find anything useful on Internet.
In - (BOOL)loadWithPlayerParams:(NSDictionary *)additionalPlayerParams in YTPlayerView.m (line 617), add:
self.webView.mediaPlaybackAllowsAirPlay = YES;
right before you return YES.

Video restricted from playback on certain sites, even though embed is allowed

I am creating an iOS app that uses the youtube iOS player helper. It works fine, but for some videos, when trying to play them, I get 'This video contains content from [YYY]. It is restricted from playback on certain sites'.
The metadata for one of the videos that doesn't work is here: http://gdata.youtube.com/feeds/api/videos/KJB49SAHIKM?v=2&prettyprint=true.
And http://gdata.youtube.com/feeds/api/videos/dRgPi1OPBeA?v=2&prettyprint=true is the metadata for a video that works.
The embed permission seems to be the same. What could the problem be? Is there something I'm missing?
I know that 'syndicate' is denied for the video that doesn't work, but I also have a video with syndicate and embed allowed that doesn't play and gives the same error, so I assume there must be something else.
Also, I have access to the channels that uploaded those two videos. Are there any settings for the individual videos that have to be set for them to be able to be embedded?
Add player vars while initializing youtube sdk:
NSDictionary *playerVars = #{
#"origin" : #"http://www.youtube.com",
};
[self.playerView loadWithVideoId:#"KOvoD1upTxM" playerVars:playerVars];
Enjoy!
I had the same issue but it seems like its due to the fact that publishers have restricted the video to be played outside youtube.com. If you own the channel and videos then probably you have a setting that restricts playback of videos outside youtube. For other videos that I dont have access to I put an option to watch it on youtube that would fire up native youtube app with the video loaded.

Get streaming URL from any YouTube video

I know about how to play video in device. But Here I just want to know that is it possible to get streaming URL from any YouTube Video? Then how can I do it, I tried to search on google but I can not able to find my solution.
Generally I does not want to play direct stream from video, actually I want to save this URL (stream) in my buffer memory OR whatever temporary file and whenever user click on particular button then particular URL Stream is play.
Al Last I got YouTube APIs + iPhone = Cool mobile apps. But I am not sure that it's helpful in my case or not ? If anybody who worked on this API then please suggest me, Otherwise How can I get streaming URL.
Your suggestion will be appreciated.
Thanks in advance.
http://www.youtube.com/get_video_info?&video_id={VIDEO_ID}
This will not work on all files, some will display the message "This+video+contains+content+from.....". But many will work.
Is it possible to get streaming URL from any YouTube Video? - No, it is not possible without hurting the terms of service of youtube. Google has built the business model of youtube around the advertisements all over youtube, in-video banners and video ads and they want your user to see their ads. This is the reason they completely hide the video stream and would ban your app if you anyway access and stream it directly.
The only consented way to play youtube videos on iOS is to embed it into an iframe of a web view.

Phonegap Video player plugin for iOS [duplicate]

I am using a Phonegap plugin for playing a video in my iOS app. I'm able to play a video with the URL format like http://easyhtml5video.com/images/happyfit2.mp4.
How do I play Youtube videos using the phonegap-videoplayer-plugin?
YouTube Terms of Service: "You agree not to access Content
through any technology or means other than the video playback pages of
the Service itself, the Embeddable Player, or other explicitly
authorized means YouTube may designate."
There are some methods that will give you direct link to youtube videos. Use "gdata" option to find all possible video formats.
Then parse the result to get desired link. Hope this might be useful
But everywhere I found the code to be edited in .m and .h files. None have explained how to use it.
That's because you can only directly use MPMoviePlayerController from native apps (written in Objective-C). For any other technology you'll have to have an intermediary layer in between.
From googling, I found this plugin for PhoneGap that claims to integrate with MPMoviePlayerController. I've no idea if it's any good, but it might do as a starting point.
try to give the youtube url in this format.
http://www.youtube.com/embed/jxXukpxNSx4
You will get the desired result. But Autoplay is not enabled, as Apple stopped supporting autoplay to save user's bandwidth

Resources