diff --git a/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/Contents.json b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..3fa4daf20b0ea83c0a9e864f7c2a30e520282163 --- /dev/null +++ b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "pip.exit.24x24.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "pip.exit.24x24@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "pip.exit.24x24@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24.png b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24.png new file mode 100644 index 0000000000000000000000000000000000000000..ec1a859567ebb61d1a8e16d889c3dbcab9612113 Binary files /dev/null and b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24.png differ diff --git a/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24@2x.png b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..cec3107133bb3a1fab07991e22c54398d0f18221 Binary files /dev/null and b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24@2x.png differ diff --git a/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24@3x.png b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..584494155a18fdc850bab01f45af1348cadec1f0 Binary files /dev/null and b/Resources/iOS/Images.xcassets/NewPlayer/pip.exit.imageset/pip.exit.24x24@3x.png differ diff --git a/Sources/Playback/Control/VLCPlaybackService.h b/Sources/Playback/Control/VLCPlaybackService.h index f4fc636e239b371f07baacacc3e9add11e39de8c..a1a144014bb030ba4b60fc7ca9e40ed5920e31e6 100644 --- a/Sources/Playback/Control/VLCPlaybackService.h +++ b/Sources/Playback/Control/VLCPlaybackService.h @@ -50,6 +50,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom nextMedia:(VLCMedia *)media; - (void)playModeUpdated; - (void)reloadPlayQueue; +- (void)pictureInPictureStateDidChange:(BOOL)isEnabled +NS_SWIFT_NAME(pictureInPictureStateDidChange(enabled:)); @end NS_SWIFT_NAME(PlaybackService) diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 362b6de28562fbb6de4037e99c51ca517bd7f99e..381d18763e58579706e2e82cfdd00defbf159e05 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -87,6 +87,7 @@ NSString *const VLCPlaybackServicePlaybackDidMoveOnToNextItem = @"VLCPlaybackSer } @property (weak, atomic) id<VLCPictureInPictureWindowControlling> pipController; +@property (atomic) BOOL isPipEnabled; @property (atomic) id<VLCPictureInPictureMediaControlling> mediaController; @end @@ -1856,11 +1857,19 @@ NSString *const VLCPlaybackServicePlaybackDidMoveOnToNextItem = @"VLCPlaybackSer __weak typeof(self) drawable = self; return ^(id<VLCPictureInPictureWindowControlling> pipController){ drawable.pipController = pipController; + drawable.pipController.stateChangeEventHandler = ^(BOOL isEnabled) { + drawable.isPipEnabled = isEnabled; + if ([drawable.delegate respondsToSelector:@selector(pictureInPictureStateDidChange:)]) + [drawable.delegate pictureInPictureStateDidChange:isEnabled]; + }; }; } - (void)togglePictureInPicture { - [self.pipController startPictureInPicture]; + if (self.isPipEnabled) + [self.pipController stopPictureInPicture]; + else + [self.pipController startPictureInPicture]; } @end diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index 4ef3750d1511207a1ed0a756c931a0826ff01117..29c7523ea044a27922080ee3ba823ad9f57fb9ff 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -910,6 +910,10 @@ class PlayerViewController: UIViewController { // MARK: - VLCPlaybackServiceDelegate extension PlayerViewController: VLCPlaybackServiceDelegate { + func pictureInPictureStateDidChange(enabled: Bool) { + mediaNavigationBar.updatePictureInPictureButton(enabled: enabled) + } + func playbackPositionUpdated(_ playbackService: PlaybackService) { mediaScrubProgressBar.updateInterfacePosition() } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaNavigationBar.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaNavigationBar.swift index 8962a0fb97f3087f8f062ea9fac3347875c7dbdb..9d9075b9aea45c58392a9d7de92ac1745b9549ce 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaNavigationBar.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaNavigationBar.swift @@ -254,6 +254,11 @@ private enum RendererActionSheetContent: Int, CaseIterable { closePlaybackButton.accessibilityLabel = accessibility.0 closePlaybackButton.accessibilityHint = accessibility.1 } + + func updatePictureInPictureButton(enabled:Bool) { + let image = UIImage(named: enabled ? "pip.exit" : "pip.enter") + pictureInPictureButton.setImage(image, for: .normal) + } } extension MediaNavigationBar: ActionSheetDelegate, ActionSheetDataSource {