2013-07-27 54 views
1

我想爲iPhone開發一個應用程序。這是我的第一個iPhone應用程序,請耐心等待。我目前正在將Icecast的MP3音頻流式傳輸到android上。但我無法弄清楚如何在iPhone上做同樣的事情。我已經閱讀了許多有關HLS的文章,但是我可以通過Icecast來做到嗎?還是有另一種選擇?流直播從Icecast到iPhone的應用程序的

+0

你的Icecast流僅僅是HTTP。您可能會發現尋找非HLS HTTP流更好運氣。此外,這已在StackOverflow上多次討論過。你嘗試過什麼? – Brad

回答

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

    } 
} 

}

+0

您是否看過iOS示例代碼中的SpeakHere代碼?https://developer.apple.com/LIBRARY/IOS/samplecode/SpeakHere/Introduction/Intro.html – koherent