Only try to stop video when it *is* a video

// FREEBIE
This commit is contained in:
Michael Kirk 2018-03-19 20:28:43 -04:00
parent f037101af6
commit 428802aee8
3 changed files with 11 additions and 7 deletions

View File

@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)playVideo;
// Stops playback and rewinds
- (void)stopVideo;
- (void)stopAnyVideo;
- (void)setShouldHideToolbars:(BOOL)shouldHideToolbars;
- (void)zoomOutAnimated:(BOOL)isAnimated;

View File

@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)dealloc
{
[self stopVideo];
[self stopAnyVideo];
}
- (instancetype)initWithGalleryItemBox:(GalleryItemBox *)galleryItemBox
@ -576,6 +576,13 @@ NS_ASSUME_NONNULL_BEGIN
[self.delegate mediaDetailViewController:self isPlayingVideo:NO];
}
- (void)stopAnyVideo
{
if (self.isVideo) {
[self stopVideo];
}
}
- (void)stopVideo
{
OWSAssert(self.isVideo);

View File

@ -190,7 +190,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
public func didPressAllMediaButton(sender: Any) {
Logger.debug("\(logTag) in \(#function)")
currentViewController.stopVideo()
currentViewController.stopAnyVideo()
guard let mediaGalleryDataSource = self.mediaGalleryDataSource else {
owsFail("\(logTag) in \(#function) mediaGalleryDataSource was unexpectedly nil")
@ -335,10 +335,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
// Do any cleanup for the no-longer visible view controller
if transitionCompleted {
previousPage.zoomOut(animated: false)
if previousPage.galleryItem.isVideo {
previousPage.stopVideo()
}
previousPage.stopAnyVideo()
updateFooterBarButtonItems(isPlayingVideo: false)
}
}