0
我正在實施基於音頻的應用程序。我用兩個AVPlayers播放兩種不同的聲音。一旦聲音播放,我需要做不同的動作。爲此,我使用了NSNotifications。但我的問題是我無法找到與哪個播放器相關的通知。我的通知代碼和選擇器代碼如下,請任何人告訴我我做了什麼錯誤。帶參數的NSNotificationCenter
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playingItemDidEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:iPodPlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playingItemDidEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:applicationPlayer ];
- (void)playingItemDidEnd:(NSNotification *)notification
{
id object= [notification object];
if(object==ipodPlayer)
{
printf("\n Notification from iPod Player ");
}
else if(object==applicationPlayer)
{
printf("\n Notification from application Player ");
}
}
在此先感謝, 錢德拉。