StreetVoice / HysteriaPlayer

Objective-C audio player, sitting on top of AVPlayer
Other
583 stars 99 forks source link

How can I play simple array of mp3 files from folder in my app? #3

Closed Samback closed 11 years ago

Samback commented 11 years ago

It is not clear for me how can I just feed player with mp3 array that lay on my app folder. For example mp3Array = @[@"1.mp3", @"2.mp3", @"3.mp3"]; I have try also mp3Array = @[ [[NSBundle mainBundle]pathForResource:@"1" ofType:@"mp3"], [[NSBundle mainBundle]pathForResource:@"2" ofType:@"mp3"], [[NSBundle mainBundle]pathForResource:@"3" ofType:@"mp3"]];

saiday commented 11 years ago

Because this class is for remote media only, so it can't play local mp3 media.

Samback commented 11 years ago

So, it's no way how to put my mp3 files there? Maybe I could feed it using something like this

NSString filepath = [[NSBundle mainBundle]pathForResource:@"point1sec" ofType:@"mp3"]; if ([[NSFileManager defaultManager]fileExistsAtPath:filepath]) { isInEmptySound = YES; AVPlayerItem playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:filepath]]; audioPlayer = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObject:playerItem]]; } ?

saiday commented 11 years ago

Yes, use AVQueuePlayer or AVAudioPlayer directly is what you need to do. Apple AVAudioFramework supports local media file flawlessly, not like remote media playback. HysteriaPlayer only focused on remote media to do things such as pre-buffer, bad network suspend-restart etc..

Short Answer: If you want to play local media file, use AVAudioPlayer or AVQueuePlayer.

Thanks!

Samback commented 11 years ago

Thanks for response.

saiday commented 11 years ago

:dancers: