From 54d5c3966fbfa024bf2da0e80b0bff26fff3f500 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Thu, 17 Aug 2017 15:04:14 +0200 Subject: [PATCH] Send previous playback informations that are reset with a stop --- Framework/Sources/Player/SRGMediaPlayerController.m | 6 +++--- Tests/Sources/PlaybackTestCase.m | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Framework/Sources/Player/SRGMediaPlayerController.m b/Framework/Sources/Player/SRGMediaPlayerController.m index cf198550..12ae8d10 100644 --- a/Framework/Sources/Player/SRGMediaPlayerController.m +++ b/Framework/Sources/Player/SRGMediaPlayerController.m @@ -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; } @@ -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; } diff --git a/Tests/Sources/PlaybackTestCase.m b/Tests/Sources/PlaybackTestCase.m index b7dd2a95..6e471ffb 100644 --- a/Tests/Sources/PlaybackTestCase.m +++ b/Tests/Sources/PlaybackTestCase.m @@ -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;