How to play an array of songs using streamingkit library - ios

Has anyone out there ever used this https://github.com/tumtumtum/StreamingKit/ package to play remote mp3 files? How can one load an array of music urls and play them one after the other?

Just as document says:
STKAudioPlayer* audioPlayer = [[STKAudioPlayer alloc] init];
[audioPlayer queue:#"http://www.abstractpath.com/files/audiosamples/sample.mp3"];
[audioPlayer queue:#"http://www.abstractpath.com/files/audiosamples/airplane.aac"];
You just need to add url to queue.

Related

Playing several tracks saved locally in sequence

I need to play n tracks one after another with ability to switch to next/previous song and pause. Songs are located in Documents folder.
I looked in AVQueuePlayer, but it seems that this approach is not working with local files, playing by url works fine. Now i can play one song with AVAudioPlayer like this:
NSURL *url = [NSURL fileURLWithPath:[node path]];
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[self.player play];
But it seems that playing bunch of tracks one after another this way is not the best practice.
May be there are frameworks that implement this in more convenient way?
Any suggestions?
StreamingKit is probably what your looking for.

how to play mp3 streaming in objectives c

I have this stream url with mp3 type: http://www.slobodnyvysielac.sk/redata/other/play.php?file=informacna%20vojna%20-%202015-02-17%20financne%20skupiny.mp3
when I open this url with Safari or Chrome, it can play, but I can't play it with objectives C code (iOS).
Please tell me the solution!
Thanks all!
player = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:#"http://archive.slobodnyvysielac.sk/informacna%20vojna%20-%202015-02-10%20hudo.mp3"]];
[player play];
Inside your view controller or whatever class you have define this, don't define it inside the event where you stream.
AVPlayer *player
EDIT:
There was a problem with your URL, if you open it in the browser, it opens a flash player so I inspected the flash object and got the original MP3 url which will stream, and you can compare how Google Chrome e.g. reacts to both URLs to notice the difference, now the url in my above code is the correct one

How to stream mp3 files (iOS)

I have found many related questions on SO, but or because I am very new, or because it doesn't exactly fit my problem, I can't find a way to succeed.
So, all I would like to do is playing an audio file stored on an exernal server directly on the iOS device (iPhone in my case)
I have tried differents solution on the net, and this is what I get until now.
NSString* resourcePath = #"http://www.chiptape.com/chiptape/sounds/medium/laugh.mp3"; //your url
NSURL *url = [[NSURL alloc]initWithString:resourcePath];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithURL:url error:&error];
audioPlayer.delegate = self;
[url release];
[audioPlayer prepareToPlay];
[audioPlayer play];
The compiler show me this error:
No visible #interface for 'AVAudioPlayer' declares the selector
'initWithURL:error:'
I am not sure at all about my code, and would like your guys to know I have started iOS coding yesterday, so it's not impossible I'm missing something so obvious that tutorials/posts don't mention it.
Also, I have imported the library AVFoundation and imported it on my .h file.
I have also declared this on my .h file
AVAudioPlayer *audioPlayer;
I hope there is an easy way to stream audio file on iOS as provide android/java
Thank you and if you need more details comment and I'll update my post.
Try this:
NSString* resourcePath = #"http://www.chiptape.com/chiptape/sounds/medium/laugh.mp3"; //your url
NSURL *audioURL = [NSURL URLWithString:resourcePath];
AVAudioPlayer *audioPlayer = [[[AVAudioPlayer alloc] initWithContentsOfURL: audioURL error:&error]autorelease];
[audioPlayer play];
I'm working with it recently.
AVAudioPlayer can't work with audio stream. In fact, there isn't an easy way to do that.
You need to learn some Core Audio things, get the raw data of media, play them in audioQueue (audioToolBox framework). Real-time audio processing is not a simple work, it's full of c-level api and so many dirty work, don't rush, have fun :)
Check out the book Learning Core Audio and this open-source audio streamer.
Let me know if you need more help.

AVAudioPlayer not working with .pls shoutcast file?

Good Day,
I am working on one Radio APP that gets shoutcast streaming .pls file and plays it with help of AVFoundation framework.
This job is easily done with AVPlayer, but the problem with it is that I can not code or find any good solution to get it working with volume slider, the AVPlayer class does not have volume property.
So now I am trying to get it working with AVAudioPlayer which has volume property, and here is my code:
NSString *resourcePatch = #"http://vibesradio.org:8002/listen.pls";
NSData *_objectData = [NSData dataWithContentsOfURL:[NSURL URLWithString:resourcePatch]];
NSError *error;
vPlayer = [[AVAudioPlayer alloc] initWithData:_objectData error:&error];
vPlayer.numberOfLoops = 0;
vPlayer.volume = 1.0f;
if (vPlayer == nil)
NSLog(#"%#", [error description]);
else
[vPlayer play];
This code is working with uploaded .mp3 files on my server but it is not working with .pls files generated by shoutcast,
Is there any way to fix AVAudioPlayer to work with .pls files, or implement volume slider to AVPlayer ?
Using AVAudioPlayer for stream from network is not a good idea. See what Apple's documentation say on AVAudioPlayer:
An instance of the AVAudioPlayer class, called an audio player,
provides playback of audio data from a file or memory.
Apple recommends that you use this class for audio playback unless you
are playing audio captured from a network stream or require very low
I/O latency.
For change AVPlayer's volume check this question:Adjusting the volume of a playing AVPlayer

MPMoviePlayerController stills play after delete mp3 source file?

I'm writing a app to play media file.I use MPMoviePlayerController.
My source:
NSURL * mp3URL = [NSURL fileURLWithPath:mp3Path];
MPMoviePlayerController *mpv = [[MPMoviePlayerController alloc] init];
[mpv setContentURL:mp3URL];
But when i delete mp3Path,mpv stills play.
In this case,MPMoviePlayer creates a tmp file,load data from mp3Path to tmp path and play this tmp file?
Can anyone explain to me?Thanks so much.
yes it creates a tmp file, thats why you have the notifications for didloadfinish and didpreloadfinish if the file did load completely it is gonna play the whole song...

Resources