Use TimedMetadata when the current playback time matches the start time.
Use the saved dictionary from the previous topic to actually use these saved PTTimedMetadata objects during playback.
- (void) onMediaPlayerTimeChange:(NSNotification *)notification
{
CMTimeRange seekableRange = self.player.seekableRange;
if (CMTIMERANGE_IS_VALID(seekableRange))
{
int currentTime = (int) CMTimeGetSeconds(self.player.currentTime);
NSArray *allKeys = timedMetadataCollection ? [timedMetadataCollection allKeys] : [NSArray array];
NSMutableArray *timedMetadatasToDelete = [[[NSMutableArray alloc] init] autorelease];
int count = [allKeys count];
for (int i=count - 1; i > -1; i--)
{
NSNumber *currTimedMetadataTime = allKeys[i];
if ([currTimedMetadataTime integerValue] == currentTime)
{
/*
Use the timed metadata here and remove it from the collection.
*/
NSLog (@"IN PLAYBACK TIME %i TO EXECUTE TIMEDMETADATA %@ scheduled at time %f",currentTime,currTimedMetadata.name,CMTimeGetSeconds(currTimedMetadata.time));
PTTimedMetadata *currTimedMetadata = [timedMetadataCollection objectForKey:currTimedMetadataTime];
[timedMetadatasToDelete addObject:currTimedMetadataTime];
}
}
for (int i=0; i<[timedMetadatasToDelete count]; i++)
{
NSNumber *timedMetadataToDelete = timedMetadatasToDelete[i];
[timedMetadataCollection removeObjectForKey:timedMetadataToDelete];
}
}
}