Skip to content

Commit

Permalink
Send previous playback informations that are reset with a stop
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby committed Aug 17, 2017
1 parent c4f934b commit 54d5c39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Framework/Sources/Player/SRGMediaPlayerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,6 @@ - (void)reset
if (self.contentURL) {
userInfo[SRGMediaPlayerPreviousContentURLKey] = self.contentURL;
}
userInfo[SRGMediaPlayerPreviousTimeRangeKey] = [NSValue valueWithCMTimeRange:self.timeRange];
userInfo[SRGMediaPlayerPreviousMediaTypeKey] = @(self.mediaType);
userInfo[SRGMediaPlayerPreviousStreamTypeKey] = @(self.streamType);
if (self.userInfo) {
userInfo[SRGMediaPlayerPreviousUserInfoKey] = self.userInfo;
}
Expand Down Expand Up @@ -825,6 +822,9 @@ - (void)stopWithUserInfo:(NSDictionary *)userInfo
// Only reset if needed (this would otherwise lazily instantiate the view again and create potential issues)
if (self.player) {
fullUserInfo[SRGMediaPlayerLastPlaybackTimeKey] = [NSValue valueWithCMTime:self.player.currentTime];
fullUserInfo[SRGMediaPlayerPreviousTimeRangeKey] = [NSValue valueWithCMTimeRange:self.timeRange];
fullUserInfo[SRGMediaPlayerPreviousMediaTypeKey] = @(self.mediaType);
fullUserInfo[SRGMediaPlayerPreviousStreamTypeKey] = @(self.streamType);
self.player = nil;
}

Expand Down
8 changes: 5 additions & 3 deletions Tests/Sources/PlaybackTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -1110,11 +1110,13 @@ - (void)testStop

// No previous playback information since it has not changed
XCTAssertNil(notification.userInfo[SRGMediaPlayerPreviousContentURLKey]);
XCTAssertNil(notification.userInfo[SRGMediaPlayerPreviousMediaTypeKey]);
XCTAssertNil(notification.userInfo[SRGMediaPlayerPreviousTimeRangeKey]);
XCTAssertNil(notification.userInfo[SRGMediaPlayerPreviousStreamTypeKey]);
XCTAssertNil(notification.userInfo[SRGMediaPlayerPreviousUserInfoKey]);

// Previous playback information since it has changed
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousMediaTypeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousTimeRangeKey]);
XCTAssertNotNil(notification.userInfo[SRGMediaPlayerPreviousStreamTypeKey]);

TestAssertEqualTimeInSeconds([notification.userInfo[SRGMediaPlayerLastPlaybackTimeKey] CMTimeValue], 0);

return YES;
Expand Down

0 comments on commit 54d5c39

Please sign in to comment.