objective c - AVPlayer got the metadata but not playing -
i'm trying simple application, purpose listening audio stream (aac 64 kbps). i'm using avplayer
apple avfoundation
has follow :
viewcontroller.m
#import "viewcontroller.h" @interface viewcontroller () @end @implementation viewcontroller @synthesize playeritem, player; - (void)viewdidload { [super viewdidload]; } - (void) viewwillappear:(bool)animated{ [super viewwillappear:animated]; playeritem = [avplayeritem playeritemwithurl:[nsurl urlwithstring:@"http://stream.myjungly.fr/myjungly2"]]; [playeritem addobserver:self forkeypath:@"timedmetadata" options:nskeyvalueobservingoptionnew context:nil]; player = [avplayer playerwithplayeritem:playeritem]; [player play]; nslog(@"player item error : %@", playeritem.error.description); nslog(@"player error : %@", player.error.description); } - (void) observevalueforkeypath:(nsstring*)keypath ofobject:(id)object change:(nsdictionary*)change context:(void*)context { if ([keypath isequaltostring:@"timedmetadata"]) { avplayeritem* _playeritem = object; (avmetadataitem* metadata in _playeritem.timedmetadata) { nslog(@"\nkey: %@\nkeyspace: %@\ncommonkey: %@\nvalue: %@", [metadata.key description], metadata.keyspace, metadata.commonkey, metadata.stringvalue); } } } @end
my object player
, playeritem
strong properties :
viewcontroller.h
@interface viewcontroller : uiviewcontroller @property (nonatomic, strong) avplayeritem* playeritem; @property (nonatomic, strong) avplayer* player; @end
the key value observer working great, here log :
2013-05-14 11:18:03.725 musicavplayer[6494:907] player item error : (null) 2013-05-14 11:18:03.728 musicavplayer[6494:907] player error : (null) 2013-05-14 11:18:08.140 musicavplayer[6494:907] key: title keyspace: comn commonkey: title value: alabama shakes - mine
but audio not played, i've go no sound ! idea why ?
edit: @ questions :
avaudioplayer not playing sound
that's why i'm using strong property, guess problem not arc related
i found problem : iphone in silent mode ... no sound can go out on speaker, the sound played when using head phone.
but i've got new question : how can play sound on speaker when phone in silent mode ? (like official music application)
edit : ... , answer there : play sound on iphone in silent mode
Comments
Post a Comment