Using AVPlayer for streamed audio, when I select a audio, I call
[mySong addObserver:self forKeyPath:@"status" options:0 context:nil]
I then use
observeValueForKeyPath: ofObject: change: context:
to observe the [ofObject status] for the standard three values:
AVPlayerStatusReadyToPlay, AVPlayerStatusUnknown, and AVPlayerStatusFailed
and call the button's -setBackgroundImage ("Stop" version) when
AVPlayerStatusReadyToPlay.
My question is:
Do I have to set up a 2nd KVO call-back method to monitor whether the selected
audio has ended naturally? I need to know when the audio is finished so I can
call the set the button's backgroundImage to the "Play" variety.
For example, according to the AV Foundation Programming Guide, I'm supposed to
use:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[player currentItem]];
Is there any way of using just one call-back for both PlayerStatus and
DidPlayToEnd?
Someone else suggested having each method call a 3rd common one … but if I do
that, I might as well stay with 2.
I sure would like to just use [NSNotificationCenter defaultCenter] addObserver:
… and combine in it my [mySong addObserver: method.
Thanks bunches.
John Love
Touch the Future! Teach!
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]