ios - addObserver forkeypath not working in MPMusicPlayerController -


i using following code know currentplayback time. not working when play song using mpmusicplayercontroller.help me on this. ideas or suggestions grateful

[self addobserver:self forkeypath:@"musicplayer.currentplaybacktime" options:0 context:nil]; 

song play code

mpmediaitemcollection *collection = [[mpmediaitemcollection alloc] initwithitems:[nsarray arraywithobject:song]]; [musicplayer setqueuewithitemcollection:collection];  [musicplayer preparetoplay]; [musicplayer setnowplayingitem:song]; //[self.musicplayer setvolume:volumeslider.value]; [musicplayer play]; 

as stated volker, property not kvo compliant. see docs here nsnotification events listen for. make sure call

[musicplayer begingeneratingplaybacknotifications] 

and

[musicplayer endgeneratingplaybacknotifications] 

for reference these notifications posted mpmusicplayercontroller:

mpmusicplayercontrollerplaybackstatedidchangenotification mpmusicplayercontrollernowplayingitemdidchangenotification mpmusicplayercontrollerplaybackstatedidchangenotification mpmusicplayercontrollernowplayingitemdidchangenotification 

https://developer.apple.com/library/ios/documentation/mediaplayer/reference/mpmusicplayercontroller_classreference/chapters/reference.html#//apple_ref/occ/instm/mpmusicplayercontroller/begingeneratingplaybacknotifications


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -