4 つの AVPlayerItems の配列から作成している AVQueuePlayer があり、すべて正常に再生されます。
キューの最後のアイテムの再生が終了したら何かをしたいのですが、ここでたくさんの答えを見てきましたが、これは私が望むものに対して最も有望に見えるものです: サウンドが終了した後にコードを実行する最良の方法遊んでいる
私のボタンハンドラーには、次のコードがあります。
static const NSString *ItemStatusContext;
[thePlayerItemA addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd)
name:AVPlayerItemDidPlayToEndTimeNotification
object:thePlayerItemA];
theQueuePlayer = [AVQueuePlayer playerWithPlayerItem:thePlayerItemA];
[theQueuePlayer play];
そして、playerItemDidReachEnd を処理する関数があります。
- (void)playerItemDidReachEnd:(NSNotification *)notification {
// Do stuff here
NSLog(@"IT REACHED THE END");
}
しかし、これを実行すると、Internal Inconsistency Exception が発生します。
An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: status
Observed object: <AVPlayerItem: 0x735a130, asset = <AVURLAsset: 0x73559c0, URL = file://localhost/Users/mike/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/A0DBEC13-2DA6-4887-B29D-B43A78E173B8/Phonics%2001.app/yes.mp3>>
Change: {
kind = 1;
}
私は何を間違っていますか?