user1940888
user1940888

Reputation: 475

How to stream online radio from SHOUTCast in my iOS App?

I am developing an iPhone Online Radio Streamer App. I used Matt Gallaher's AudioStreamer class to stream online tune in stations from SHOUTCast. But the problem is that the AudioStreamer API has been abandoned and fails to play various radio channels. I have googled and found various alternatives including: AVPlayer, MPMoviePlayer etc.

Please recommend which player will fulfill the requirement best.

Upvotes: 3

Views: 4012

Answers (2)

Aravindh
Aravindh

Reputation: 1

// viewcontroller.h

MPMoviePlayerViewController *moviePlayer;

//viewcontroller.m

This is implemented in viewDidLoad

moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",@"http://sample url"]]];

[moviePlayer.moviePlayer prepareToPlay];

moviePlayer.view.hidden = YES;

[self.view addSubview:moviePlayer.view];

[moviePlayer.moviePlayer play];

Upvotes: 0

Vishal
Vishal

Reputation: 8256

You can use MPMovieplayerviewcontroller. It is perfect for streaming audio/video. I am also

use this for streaming audio in one of my App & also it looks like default player of iPhone.

Ok here is coding for use of this player as I am doing in my project:

     NSString *geturl = [[radiotablearray objectAtIndex:btntag]objectForKey:@"iurl"];
    NSLog(@"geturl..%@",geturl);
    NSURL *fileURL=[NSURL URLWithString:geturl];
    NSLog(@"fileURL..%@",fileURL);
    moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
    [moviePlayerController.moviePlayer prepareToPlay];
    moviePlayerController.moviePlayer.shouldAutoplay=YES;
    moviePlayerController.view.frame = self.view.frame;
    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];
[moviePlayerController.moviePlayer play];

Also add mediaplayer & Avfoundation framework in App.And add or import these two in .h file:

#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>

& import #import <MediaPlayer/MediaPlayer.h>this in .m file. also make property of player like below in .h file:

MPMoviePlayerViewController *moviePlayerController;
 @property(strong,retain)  MPMoviePlayerViewController *moviePlayerController;

And add method where you want but also make changes in code according to your need I am just send you my implement code you just change it with your requirement. If you have any problem then ask me. Best of luck.

Upvotes: 3

Related Questions