4

I'm trying to get a .pls stream from a shoutcast server to play in my ios app. So far i've been unsuccessful. I've red a lot of posts on stackoverflow but non of these were of any help.

Can anyone please explain to me, if its even possible, how to get .pls to stream?

Rohit Vipin Mathews
  • 11,629
  • 15
  • 57
  • 112
Roeliee
  • 221
  • 2
  • 14

2 Answers2

7

all you need is to list the port of you radio, here is one working example: in - (void)viewDidLoad

NSURL *vibes = [NSURL URLWithString:@"http://website.com:8002"];
vPlayer = [[AVPlayer alloc] initWithURL:vibes];
self.myViewVolume = [[MPVolumeView alloc] initWithFrame:CGRectMake(20, 330, 280, 50)];
[self.myViewVolume sizeToFit];
[self.view addSubview:self.myViewVolume];

you need to create an instance of AVPlayer in your .m file , here it is vPlayer do not forget to add AVFoundation framework to you project, you can play and stop the stream with [player play] and [player stop]

One problem with AVPlayer is the lack of easy volume control, you can add one with mpViewVolume. I am also working on radio app and by far AVPlayer is the best to play shoutcast streams.

EmilDo
  • 1,177
  • 3
  • 16
  • 33
  • Thnx a bunch! One more question though. U initialize the MPVolumeView with a CGRectMake. Is there a way i can add this VolumeView to a toolbar? – Roeliee Nov 21 '12 at 21:37
  • Well I had some difficulties embedding it in UIView, have not tried to add it to toolbar, but I will definitely try to do this. If i find some solution I will comment here. Right now I am working on getting the metadata from the shoutcast stream and displaying it with UILabel. – EmilDo Nov 21 '12 at 21:42
  • If you find this out it would be really great if you could share that with me! If your interested ill post, once i find it out how to get the control in a UIView/Toolbar – Roeliee Nov 21 '12 at 21:45
  • Yes, post here. It would also be great to blog all these solutions because there is nearly no information about building radio APPs for iOS. The volume slider could be customized with this: http://tibr.me/2012/07/14/customizing-mpvolumeview-appearance/ in ios6 there is custom classes to do this but, i will do it with the instructions from the blog because not so many ppl have updated to ios6. – EmilDo Nov 21 '12 at 21:49
  • i've figured out how to add the MPVolumeView to a UIView. Its actually pretty simple. Just drag a UIView in your Storyboard/XIB, then change its class type to MPVolumeView. Works in a toolbar as well – Roeliee Nov 22 '12 at 17:06
  • Can you paste me some example for adding this object into a toolbar, i have some problems with this, probably my approach is wrong. I have working example for getting metadata from your .pls stream, it is really easy. If you want it- send me an email to emido499@student.liu.se It seems that i can not add it as comment here – EmilDo Nov 23 '12 at 20:14
  • Was I banging my head here and there for so simple thing?? Dude you have made my life so much easier :-D – Salman Zaidi Apr 22 '13 at 18:28
  • You cannot use MPVolumeView from simulator. – Mashhadi Nov 25 '14 at 14:03
2

@Walid Hussain it worked for me using AVPlayer

link with AVFoundation.framework

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

// declaration for the player  
AVPlayer * radioPlayer;

// play
NSURL * url = [NSURL URLWithString:@"http://energy10.egihosting.com:9636"];
radioPlayer = [[AVPlayer playerWithURL:url] retain];
[radioPlayer play];
Ammarz
  • 340
  • 2
  • 9