3

I have several questions about audio streaming :

What i want to do is stream some mp3 files, between 3 and 7 mins (mostly music files) but these mp3 are provided by a server which is not mine. I precise that i want my app to be accepted in the appstore of course...

1 °/ I need to stream some mp3 music file over http, they are encoded at 128Kbps. Do I really need the HTTP Live Streaming service (HLS) ?

2 °/ If I have to use the HLS, do i have to re-encode my mp3 files to 64Kbps or just segmentate them ?

Thanks!

  • I have not done an audio streaming.. I dont think you need an HLS for Audio streaming... see my post in this link for video streaming http://stackoverflow.com/questions/10597884/iphone-ipad-downloading-and-playing-simultaneously/10601021#10601021 – Dilip Rajkumar Jun 02 '12 at 15:44
  • Did you try to play the audio i.e mp3 by just giving the URL to the player directly. – Dilip Rajkumar Jun 02 '12 at 15:44

1 Answers1

0

I am using this code to play audio..As far I know you dont need to use HLS you can stream as it is.. or you have to move the metadata of the audio.. I have given the steps in another answer iPhone/iPad Downloading and Playing Simultaneously.. Please check..

// add the necessary frameworks    
#import <CoreAudio/CoreAudioTypes.h>
#import <AVFoundation/AVFoundation.h>
// put the code in .h file
AVAudioPlayer * avPlayer;

-(IBAction) stopPlayingAudio {
    [avPlayer stop];
}

- (IBAction)showVoiceRecordingMenu
{

    // Create an otherwise-empty alert sheet
    avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://test.com/audio/files/audioFile.mp3"] error:&error];

    NSLog(@"%@", [filePath path] ); 
    NSLog(@"%f", avPlayer.duration );
    itsAudioDuration = avPlayer.duration;
    [avPlayer prepareToPlay];
    [avPlayer play];
}
Community
  • 1
  • 1
Dilip Rajkumar
  • 7,006
  • 6
  • 60
  • 76
  • Thanks for answering ! But I know how to stream music from an mp3. I just want to know if my app gonna be rejected from the appstore if i don't use HLS to stream my mp3... –  Jun 02 '12 at 22:07
  • I've tried this code (and others that were similar) and nothing plays. I also do not see any hits to the server. I've checked my URL is correct. AVAudioPlayer takes no action when I tell it to play. – Matt Jan 17 '13 at 21:40
  • Sorry for the late response Matt.. I am out of station .. Can u give me the file URL? – Dilip Rajkumar Jan 20 '13 at 11:37
  • 1
    The AVAudioPlayer does not support HTTP resources. https://developer.apple.com/library/ios/#qa/qa2009/qa1634.html – kain Feb 06 '13 at 17:54
  • @kain sorry I answered long before and i do not remember anything.. if you know the correct answer please answer to the question.. it will help some one in future.. – Dilip Rajkumar Feb 07 '13 at 20:37
  • Changing AVAudioPlayer to AVPlayer worked for me, pretty much the same code but streams from http resources no problem! http://stackoverflow.com/questions/13131177/streaming-mp3-audio-with-avplayer?lq=1 – Jack Dewhurst Jan 13 '14 at 12:55