[vlc-commits] [Git][videolan/vlc][master] macosx: Make the video view dismissible while retaining playback in background...

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Sep 9 09:45:10 UTC 2022



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
fa49f8c3 by Claudio Cambra at 2022-09-09T09:11:28+00:00
macosx: Make the video view dismissible while retaining playback in background in main library window

Signed-off-by: Claudio Cambra <claudio.cambra at gmail.com>

- - - - -


6 changed files:

- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h
- modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -335,8 +335,24 @@
                                         <subviews>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="5o7-Z0-dqS" userLabel="Artwork image view" customClass="VLCImageView">
                                                 <rect key="frame" x="16" y="8" width="60" height="60"/>
+                                                <subviews>
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="15t-2s-22l">
+                                                        <rect key="frame" x="0.0" y="0.0" width="60" height="60"/>
+                                                        <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="jRw-La-BEz">
+                                                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                                            <font key="font" metaFont="system"/>
+                                                        </buttonCell>
+                                                        <connections>
+                                                            <action selector="artworkButtonAction:" target="Uzf-Tf-H8x" id="am9-q0-AXg"/>
+                                                        </connections>
+                                                    </button>
+                                                </subviews>
                                                 <constraints>
+                                                    <constraint firstItem="15t-2s-22l" firstAttribute="top" secondItem="5o7-Z0-dqS" secondAttribute="top" id="AS7-P7-l0D"/>
+                                                    <constraint firstItem="15t-2s-22l" firstAttribute="leading" secondItem="5o7-Z0-dqS" secondAttribute="leading" id="Aq6-SV-NCD"/>
                                                     <constraint firstAttribute="height" constant="60" id="CtN-ax-WYl"/>
+                                                    <constraint firstAttribute="bottom" secondItem="15t-2s-22l" secondAttribute="bottom" id="VGx-AQ-FZ1"/>
+                                                    <constraint firstAttribute="trailing" secondItem="15t-2s-22l" secondAttribute="trailing" id="l3U-tz-a1t"/>
                                                     <constraint firstAttribute="width" constant="60" id="oVs-dj-viy"/>
                                                 </constraints>
                                             </customView>
@@ -717,6 +733,7 @@
         <customObject id="Uzf-Tf-H8x" userLabel="Detached Window Controls Bar" customClass="VLCMainWindowControlsBar">
             <connections>
                 <outlet property="artistNameTextField" destination="0jI-HH-uWa" id="ftC-MD-ymJ"/>
+                <outlet property="artworkButton" destination="15t-2s-22l" id="aR1-bU-1to"/>
                 <outlet property="artworkImageView" destination="5o7-Z0-dqS" id="Pns-yT-lKx"/>
                 <outlet property="backwardButton" destination="jGc-Xw-GYI" id="0AG-44-SN3"/>
                 <outlet property="bottomBarView" destination="vUy-jt-gjY" id="WqX-SW-mpv"/>


=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -561,6 +561,10 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
 
 + (nullable instancetype)mediaItemForURL:(NSURL *)url
 {
+    if(url == nil) {
+        return nil;
+    }
+
     vlc_medialibrary_t *p_mediaLibrary = getMediaLibrary();
     if(!p_mediaLibrary) {
         return nil;


=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -102,6 +102,7 @@ typedef NS_ENUM(NSUInteger, VLCViewModeSegment) {
 @property (readwrite, weak) IBOutlet NSButton *playQueueToggle;
 @property (readwrite, weak) IBOutlet NSButton *backwardsNavigationButton;
 @property (readwrite, weak) IBOutlet NSButton *forwardsNavigationButton;
+ at property (readwrite, weak) IBOutlet NSButton *artworkButton;
 
 @property (readonly) BOOL nativeFullscreenMode;
 @property (readwrite) BOOL nonembedded;
@@ -117,6 +118,7 @@ typedef NS_ENUM(NSUInteger, VLCViewModeSegment) {
 @property (readonly) VLCFSPanelController *fspanel;
 
 - (void)videoPlaybackWillBeStarted;
+- (void)reopenVideoView;
 
 - (IBAction)playlistDoubleClickAction:(id)sender;
 - (IBAction)shuffleAction:(id)sender;


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #import "VLCLibraryWindow.h"
+#include "VLCLibraryDataTypes.h"
 #import "extensions/NSString+Helpers.h"
 #import "extensions/NSFont+VLCAdditions.h"
 #import "extensions/NSColor+VLCAdditions.h"
@@ -239,6 +240,14 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
                            selector:@selector(updateViewCellDimensionsBasedOnSetting:)
                                name:VLCConfigurationChangedNotification
                              object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(playerStateChanged:)
+                               name:VLCPlayerCurrentMediaItemChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(playerStateChanged:)
+                               name:VLCPlayerStateChanged
+                             object:nil];
 
     if (@available(macOS 10.14, *)) {
         [[NSApplication sharedApplication] addObserver:self
@@ -835,7 +844,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
 
 - (IBAction)backwardsNavigationAction:(id)sender
 {
-    [_navigationStack backwards];
+    self.videoView.hidden ? [_navigationStack backwards] : [self disableVideoPlaybackAppearance];
 }
 
 - (IBAction)forwardsNavigationAction:(id)sender
@@ -857,6 +866,31 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     hasActiveVideo ? [self enableVideoPlaybackAppearance] : [self disableVideoPlaybackAppearance];
 }
 
+- (void)playerStateChanged:(NSNotification *)notification
+{
+    if(_playlistController.playerController.playerState != VLC_PLAYER_STATE_PLAYING) {
+        return;
+    }
+
+    [self reopenVideoView];
+}
+
+// This handles reopening the video view when the user has closed it.
+- (void)reopenVideoView
+{
+    if(!self.hasActiveVideo || !self.videoView.hidden) {
+        return;
+    }
+
+    VLCMediaLibraryMediaItem *mediaItem = [VLCMediaLibraryMediaItem mediaItemForURL:_playlistController.playerController.URLOfCurrentMediaItem];
+
+    if(mediaItem == nil || mediaItem.mediaType != VLC_ML_MEDIA_TYPE_VIDEO) {
+        return;
+    }
+
+    [self enableVideoPlaybackAppearance];
+}
+
 - (void)enableVideoPlaybackAppearance
 {
     [_mediaSourceView removeFromSuperviewWithoutNeedingDisplay];
@@ -864,11 +898,17 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     [_audioLibraryView removeFromSuperviewWithoutNeedingDisplay];
 
     [self.videoView setHidden:NO];
+
+    [self.segmentedTitleControl setHidden:YES];
+    [self.forwardsNavigationButton setHidden:YES];
     [self.gridVsListSegmentedControl setHidden:YES];
     [self.librarySortButton setHidden:YES];
     [self.librarySearchField setEnabled:NO];
     [self clearLibraryFilterString];
 
+    // Repurpose the back button
+    [self.backwardsNavigationButton setEnabled:YES];
+
     if (self.nativeFullscreenMode) {
         if ([self hasActiveVideo] && [self fullscreen]) {
             [self hideControlsBar];
@@ -903,10 +943,16 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     // restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
     [self setAlphaValue:1.0];
     [self.videoView setHidden:YES];
+
+    [self.segmentedTitleControl setHidden:NO];
+    [self.forwardsNavigationButton setHidden:NO];
     [self.gridVsListSegmentedControl setHidden:NO];
     [self.librarySortButton setHidden:NO];
     [self.librarySearchField setEnabled:YES];
 
+    // Reset the back button to navigation state
+    [self.backwardsNavigationButton setEnabled:_navigationStack.backwardsAvailable];
+
     [self setViewForSelectedSegment];
 
     if (self.nativeFullscreenMode) {


=====================================
modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h
=====================================
@@ -50,6 +50,7 @@
 @property (readwrite, strong) IBOutlet VLCSlider *timeSlider;
 
 @property (readwrite, strong) IBOutlet VLCImageView *artworkImageView;
+ at property (readwrite, strong) IBOutlet NSButton *artworkButton;
 @property (readwrite, strong) IBOutlet VLCWrappableTextField *songNameTextField;
 @property (readwrite, strong) IBOutlet VLCWrappableTextField *artistNameTextField;
 @property (readwrite, strong) IBOutlet VLCTimeField *timeField;


=====================================
modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m
=====================================
@@ -25,6 +25,7 @@
 #import "VLCControlsBarCommon.h"
 
 #import "extensions/NSString+Helpers.h"
+#import "library/VLCLibraryWindow.h"
 #import "main/VLCMain.h"
 #import "playlist/VLCPlaylistController.h"
 #import "playlist/VLCPlayerController.h"
@@ -121,6 +122,11 @@
         [_playerController setVolume:VLCVolumeMaximum];
 }
 
+- (IBAction)artworkButtonAction:(id)sender
+{
+    [[VLCMain sharedInstance].libraryWindow reopenVideoView];
+}
+
 #pragma mark -
 #pragma mark Extra updaters
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fa49f8c3663540aad9a96a0d2097205550f7e83f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fa49f8c3663540aad9a96a0d2097205550f7e83f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list