Playing audio from SWF Flash Player in Objective C - ios

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!

Related

youtube and other video links not played in chromcast ios app

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.

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];

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 to switch among alternate audio streams using AVPlayer

I have a test application that uses AVPlayer to play video specified by an m3u8 HLS playlist. The playlist specifies several alternate audio streams, similar to the "Listing 10" sample playlist provided by Apple found here: http://developer.apple.com/library/ios/#technotes/tn2288/_index.html#//apple_ref/doc/uid/DTS40012238-CH1-ALTERNATE_MEDIA The app needs to be able to switch among the alternate audio streams while the video is playing. For example, the app should be able to switch among the English, French, and Spanish audio streams by the user tapping buttons in the app while the video is playing.
Which AVFoundation classes and methods would be used by the AVPlayer and its related objects to switch among the audio streams that are specified in the m3u8 playlist? I have looked at the AVFoundation class documentation but do not see how to do this.
A link to some sample code that shows how to do this would be great. I have been searching the web for this information without success. Thanks for any help with this.
For m3u8 playback with AVPlayer, it looks like you cannot use an AVAsset to construct an AVPlayerItem. You need to construct an AVPlayerItem from the URI directly. Upon instantiating an AVPlayer with this AVPlayerItem, and then KVO listening on the property #"status", you will have an asset within the [[avPlayerInstance currentItem] asset] if the status is AVPlayerStatusReadyToPlay. This is described on page 20 of the AV Foundation Programming Guide.
To change audio to various alternates use:
AVMediaSelectionGroup *audioSelectionGroup = [[[avPlayerInstance currentItem] asset] mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicAudible];
NSLog(#"audioSelectionGroup: %#", audioSelectionGroup);
// [audioSelectionGroup options] // Array of the options in the group above.
And the select AVMediaSelectionOption (the audio channel you want) with:
[[avPlayerInstance currentItem] selectMediaOption:avMediaSelectionOptionInstance] inMediaSelectionGroup: audioSelectionGroup];
The same will work for video.
This is described in the "Selection of audio and subtitle media according to language and other criteria" section of the AV Foundation Release Notes for IOS 5 (3rd section).

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