Devesh
Devesh

Reputation:

how to stream internet radio on iphone?

Any one know how I can stream internet radio on iPhone with code? Is a provider required?

Upvotes: 13

Views: 18798

Answers (4)

Neeraj Neeru
Neeraj Neeru

Reputation: 570

yes you can play online streaming radio on your iPhone, use MPMoviePlayerController to stream your music

first you should import media player framework and audio toolbox framework

then import

 #import <MediaPlayer/MediaPlayer.h>

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:    [NSURL URLWithString:@"YOUR URL"]];
    player.movieSourceType = MPMovieSourceTypeStreaming;
    player.view.hidden = YES;
    [self.view addSubview:player.view];
    [player prepareToPlay];
    [player play];

you can stop playing music by just calling

[player stop];

thank you,

Upvotes: 6

Kemal Taskin
Kemal Taskin

Reputation: 481

You can use the AVPlayer class from the AVFoundation framework for playing streaming audio from a server. AVPlayer will only play codecs supported by the iOS SDK like mp3 and aac.

Some radio stations use the Microsoft streaming server which uses the mms:// protocol and the wma audio codec which is not supported by the iOS SDK. If you want to play these radio stations you must use a third party library like libmms or FFmpeg. The third party libraries will take care of the mms:// protocol and wma codec but you'll still need to use the Audio Queue services for playing the decoded audio data.

Upvotes: 2

John Fricker
John Fricker

Reputation: 3344

Matt Gallagher wrote a very good class for playing streaming audio on the Mac desktop and on the iPhone. See it here How To Stream Internet Radio on iPhone.

The flipside is you need a server running Nicecast, Shoutcast, Icecast or some other MP3 or AAC streaming audio software. And of course this server will need an audio connection to the radio station - either through an FM receiver, analog connection or dedicated hardware - entirely based upon the capabilities and infrastructure of the station.

Upvotes: 13

Nathan de Vries
Nathan de Vries

Reputation: 15501

iPhone OS 3.0 supports live streaming via HTTP of MPEG-2 transport streams containing AAC audio (HE-AAC or AAC-LC). You'll find everything you need to know in the HTTP Live Streaming Overview.

Upvotes: 6

Related Questions