Opening URL in youtube app does not work the first time - ios

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.

Related

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

iOS7 Can a remote webpage accessed in UIWebView access local video stored on device?

I have a webpage running on JBoss server and accessible through UIWebView in an iOS app. The webpage allows the user to view videos requested from the server. However, due to wifi connectivity issues, the request may cause video loading to be choppy.
I have code that downloads the requested video and stores it in the documents directory for my app. I think that if I put a webpage in the same directory, I can reference those videos and eliminate any wifi latency issues. However, my question is about remote, dynamic webpages running in a UIWebView - can they somehow access local videos that my app can pre-load?
Here's how I download the video currently:
NSData *downloadedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:link]];
[downloadedData writeToFile:localFilePath atomically:YES];

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!

using NSURL class refrence to view videos in my app from video app

I have videos in my ipads local video library. When I click a video in the app I created, the video opens in the local video library not in the app. Does anyone know how i can get the videos to play in the app from the local video library? using NSURL class reference
I've spoken to most of the developers I know & they tell me its not possible. I feel like if there's a will there's a way with a little help :)

How is Instapaper on iOS embedding YouTube Videos?

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..

Resources