Skip to content

Commit

Permalink
Fix segments incorrectly displayed in the info panel for livestreams …
Browse files Browse the repository at this point in the history
…without DVR

This fixes issue #236.
  • Loading branch information
defagos committed Nov 23, 2020
1 parent ee4e45a commit cd4bd7f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/SRGLetterbox/SRGLetterboxViewController~tvos.m
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,12 @@ - (void)continuousPlaybackViewController:(SRGContinuousPlaybackViewController *)
NSMutableArray<AVTimedMetadataGroup *> *navigationMarkers = [NSMutableArray array];

for (SRGSegment *segment in segments) {
SRGMediaPlayerController *mediaPlayerController = playerViewController.controller;
CMTimeRange segmentTimeRange = [segment.srg_markRange timeRangeForMediaPlayerController:mediaPlayerController];
if (! CMTimeRangeContainsTime(mediaPlayerController.timeRange, segmentTimeRange.start)) {
continue;
}

AVMutableMetadataItem *titleItem = [[AVMutableMetadataItem alloc] init];
titleItem.identifier = AVMetadataCommonIdentifierTitle;
titleItem.value = segment.title;
Expand All @@ -671,7 +677,6 @@ - (void)continuousPlaybackViewController:(SRGContinuousPlaybackViewController *)
artworkItem.value = UIImagePNGRepresentation(image);
artworkItem.extendedLanguageTag = @"und"; // Apparently not required, but added for safety / consistency

CMTimeRange segmentTimeRange = [segment.srg_markRange timeRangeForMediaPlayerController:self.playerViewController.controller];
AVTimedMetadataGroup *navigationMarker = [[AVTimedMetadataGroup alloc] initWithItems:@[ titleItem.copy, artworkItem.copy ] timeRange:segmentTimeRange];
[navigationMarkers addObject:navigationMarker];
}
Expand Down

0 comments on commit cd4bd7f

Please sign in to comment.