Question

I am trying to develop an app for the iPhone. This is my first iPhone app so please bear with me. I am currently streaming mp3 audio from Icecast to android quite easily. However I can not figure out how to do the same with the iPhone. I have read many articles on HLS, but can I do that from Icecast? Or is there another option?

Was it helpful?

Solution

AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:urlString]];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(playerItemDidReachEnd:)
                                         name:AVPlayerItemDidPlayToEndTimeNotification
                                         object:[songPlayer currentItem]];

[player addObserver:self forKeyPath:@"status" options:0 context:nil];
[player play];

}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {

    if (object == player && [keyPath isEqualToString:@"status"]) {
    if (songPlayer.status == AVPlayerStatusFailed) {
        NSLog(@"AVPlayer Failed");

    } else if (songPlayer.status == AVPlayerStatusReadyToPlay) {
        NSLog(@"AVPlayerStatusReadyToPlay");


    } else if (songPlayer.status == AVPlayerItemStatusUnknown) {
        NSLog(@"AVPlayer Unknown");

    }
}

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top