How is Instapaper on iOS embedding YouTube Videos? - ios

I trying to find a good way to embed YouTube Videos in my app. I really like the way Instapaper is embedding them but I can't figure out what YouTube Player is being used.

You should try to use the following code to play the youtube videos in the youtube app
NSString *stringURL = #"http://www.youtube.com/watch?v=qzUXXXXXXXM&feature=youtube_gdata_player";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
However if you feel you have to play the video inside your application please check following links
http://www.iphonedevsdk.com/forum/tutorial-discussion/70282-tutorial-embedding-youtube-vids.html
Embedding YouTube videos on
Hope this helps... Happy coding..

Related

AVPlayer can't play Vevo Youtube video

I'm developing my youtube app on iOS and using AVPlayer to play video. But I don't know why my player can't play the Vevo video. Any idea for my problem? Thanks a lot.
You should use the iOS Youtube Helper library for playing youtube videos.
https://developers.google.com/youtube/v3/guides/ios_youtube_helper
I don't know if you can use the AVPlayer. I've seen some examples using MPMoviePlayerController on CocoaControls, like this one: https://www.cocoacontrols.com/controls/hcyoutubeparser or this one: https://www.cocoacontrols.com/controls/xcdyoutubevideoplayerviewcontroller
But I don't think using youtube's url directly in your player fits the ToS of the platform. So I will recommend you tu use the Youtube Helper Library if you are planning to publish your app.

cloudfront video streaming not working on ios devices

I am trying to stream the video on IOS devices using amazon cloudfront web distribution(RTMP streaming is not supported by apple devices) and video is stored in s3 .Moreover the link is accessible to everyone.When I try to paste the video link in browser the video starts to download instead of streaming.
After inspecting on instagram's websites I came to know that instagram does the same thing(maybe) but the difference is it uses akamai CDN and I am using amazon's cloudfront
My link:
http://d16jy53srxox6v.cloudfront.net/brown.mp4
Instagram video streaming link:
https://igcdn-videos-b-2-a.akamaihd.net/hphotos-ak-xfa1/t50.2886-16/11773361_692383954227382_242786346_n.mp4
Where instagram video streams perfectly and my video gets download rather than streaming.After hitting google I found HLS is one of the solution yet I am looking for easy streaming alternative as my video max length would be 1 minute and HLS is good for larger files.Can anyone suggest me what should I do to make my video streamable without HLS?
Morover I tried to stream it in ios device but it tries to download and then plays it.Heres my code:
-(IBAction)click:(id)sender
{
// Make a URL
NSURL *url = [NSURL URLWithString:
#"http://d16jy53srxox6v.cloudfront.net/brown.mp4"];
// Initialize the MPMoviePlayerController object using url
_videoPlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
// Set control style to default
_videoPlayer.controlStyle = MPMovieControlStyleDefault;
// Set shouldAutoplay to YES
_videoPlayer.shouldAutoplay = YES;
_videoPlayer.movieSourceType=MPMovieSourceTypeStreaming;
// Add _videoPlayer's view as subview to current view.
[self.view addSubview:_videoPlayer.view];
// Set the screen to full.
[_videoPlayer setFullscreen:YES animated:YES];
}
Problem Might be the content type of the uploaded video
You can go to the s3 bucket and check the metadata field under properties tab
I faced the same issue with one of my videos on s3 it used to get downloaded instead of playing it.
I resolved this issue by adding metadata to the video as
Content-Type = video/mp4
hope this helps

Opening URL in youtube app does not work the first time

In my app, I open up a youtube video like such:
NSURL *youtubeURL = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:youtubeURL];
When I do this and I have the youtube app installed, it will open up youtube, but not load the video. It will just go to the youtube homepage. But if I do it again, it will load video.
I have trouble reproducing the problem, but has anyone seen this? It usually happens after not using the youtube app for a while.

How to play a .pls file in iOS?

I am trying to develop a radio application for iOS. I want to play the .pls files. I tried using AVPlayer but to no success. I retreived the URL from .pls. That also does not run. The stream however runs if I open the .pls file using the UIWebView.
Is there anything I can do to play it natively rather than using webview?
PLS link : http://66.23.234.242:8012/listen.pls
Check out this link https://discussions.apple.com/thread/1924391?start=0&tstart=0
PLS is a computer file format that stores multimedia playlists. It is a more expressive format than basic M3U, as it can store (cache) information on the song title and length — extended M3U supports this, too. With PLS version 2, playlists also include a PLS version declaration.
To play these files you need a media player on your operating system that is able to play these files. One of these media players is iTunes.
"Copied from the above mentioned link"
using MPMoviePlayer we can play .pls file and you have to hide that MPMoviePlayer, it look like a audio player and add subview to your view.
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString: #"your .pls link"]];
[moviePlayer.moviePlayer prepareToPlay];
moviePlayer.view.hidden = YES;
[self.view addSubview:moviePlayer.view];
//for play:
[moviePlayer.moviePlayer play];
//for pause:
[moviePlayer.moviePlayer stop];

Playing audio from SWF Flash Player in Objective C

I'm currently making an iOS application where you can search a song. You will then be given a list of songs which you can choose from and then stream from the app. It uses a combination of the tinysong API and I'm attempting to use a URL from Grooveshark combined with the songID given to me to play the song... E.g.
https://grooveshark.com/facebookWidget.swf?songID=13963
I've already had a quick look at this post: How can i share a grooveshark music url to facebook with the music widget?
but I was wondering if I could get more information.
What I want to do is play the audio from that link with a changing songID...
My Objective C code for this is:
//Opens the link of Url from first song and plays it
NSString *SongID = [[jsonArray objectAtIndex:0] objectForKey:#"SongID"];
NSString *playString = [#"https://grooveshark.com/facebookWidget.swf?songID=" stringByAppendingString:SongID];
//Converts songURL into a playable NSURL
NSURL *playURL = [NSURL URLWithString:playString];
AVAudioPlayer *backgroundMusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:playURL error:&error];
[backgroundMusicPlayer prepareToPlay];
[backgroundMusicPlayer play];
But it isn't playing. What should I do to make it play? I know iOS can't play Adobe flash player and considering it is in a swf format, that's why I figured it can't play but I don't know much about flash and/or it in conjunction with iOS. So any help or ideas would be much appreciated.
If there is another way to access and play songs from a massive database of songs with their artists and albums too from objective C (like spotify API, but free), please comment as that may be another solution!
Thanks!

Resources