I have to create app that provides online radio streaming (icecast), preferably .ogg format.
So I have next questions:
- How can I play .ogg format audio stream? Are there any supported
classes? Because I can't find any, so I think that it is impossible
without many bitwise operations using
CFNetwork
,CoreAudio
,AudioToolbox
etc. (I don't look at cocos2d, because it's ridiculous) Am i wrong? - I'm playing mp3 stream for now (no possibility for .ogg for me). I
tried to use
AVPlayer
,MPMovieMediaController
, AudioSreaming lib by MattGallagher and by DigitalDJ, and none of these solutions can't provides me metadata access.
For AVPlayer:
-(void)playButtonPressed:(id)sender
{
NSURL *grindURL = [NSURL URLWithString:@"http://radio.goha.ru:8000/grind.fm"];
grindFMPlayer = [[AVPlayer alloc] initWithURL:grindURL];
[grindFMPlayer.currentItem addObserver:self forKeyPath:@"status" options:0 context:nil];
AVPlayerItem *item = grindFMPlayer.currentItem;
[grindFMPlayer play];
}
-(void)stopButtonPressed:(id)sender
{
AVURLAsset *ass = grindFMPlayer.currentItem.asset;
NSArray *arr = [ass commonMetadata];
NSArray *it_meta = [grindFMPlayer.currentItem timedMetadata];
[grindFMPlayer pause];
}
arr and it_meta count always 0, no song\artist\any metadata.
The same for the MPMovieMediaController
, metadataUpdate never called
streamAudioPlayer = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL URLWithString:@"http://radio.goha.ru:8000/grind.fm"];
streamAudioPlayer.movieSourceType = MPMovieSourceTypeStreaming;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MetadataUpdate:) name:MPMoviePlayerTimedMetadataUpdatedNotification object:nil];
[streamAudioPlayer play];
and in stop button method:
timedMeta = [streamAudioPlayer timedMetadata];
if ([streamAudioPlayer timedMetadata]!=nil && [[streamAudioPlayer timedMetadata] count] > 0)
{
NSLog(@"metadata count = %d", [[streamAudioPlayer timedMetadata] count]);
for (MPTimedMetadata *metadata in [streamAudioPlayer timedMetadata])
{
NSLog(@"description %@", metadata.allMetadata);
if ([[metadata.allMetadata valueForKey:@"key"] isEqualToString:@"title"])
{
NSString *text = [metadata.allMetadata valueForKey:@"value"];
NSString* filename = text;
}
}
}
[streamAudioPlayer timedMetadata]
always nil.
I've tried
- https://github.com/mattgallagher/AudioStreamer
- https://github.com/DigitalDJ/AudioStreamer
These 2 projects for shoutcast and icecast - http://www.mikejablonski.org/2009/04/17/reading-shoutcast-metadata-from-a-stream/
But still have no luck to get current playing track info, which only obtains in SHOUTcast app as
1st Metadata = 'StreamTitle='
,
2nd metadata = ''
and bitrate = '128000'
(So I think I have to have deal with bytes from http headers response or something like this? but wtf, it's shoutcast metadata, but my radiostream is icecast. Have no idea)
I would be grateful for any help!