문제

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?

도움이 되었습니까?

해결책

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");

    }
}

}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top