[vlc-commits] [Git][videolan/vlc][master] 13 commits: macosx: Add property to player controller to check if video tracks are enabled

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Oct 17 11:14:06 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c6cf8576 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Add property to player controller to check if video tracks are enabled

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
89b8269e by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Add property to player controller to retrieve current selected video track

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
f137b373 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Remove reopenVideoView methos which just calls enableVideoPlaybackAppearance

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
48d57b76 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Do not enable video playback appearance if video track is disabled

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
d9cc0570 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Move actual fetching of selected tracks into category-agnostic internal method

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
854ce31d by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Add property to player controller to check audioTracksEnabled

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
2c45cf79 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Add property to player controller to retrieve current selected audio track

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
ca906da4 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Fix enabling video playback appearance for audio items (should show cover art video view)

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
f50ccb66 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Use VLCMainWindowControlsBar for controlsBar outlet in VLCLibraryWindow

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
3486655f by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Add ability to enable or disable a tracking view

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
e8aa06af by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Add custom inits for VLCTrackingView to correctly set up properties

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
2a71c080 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Disable artwork button and its tracking view if appropriate when playing an item

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
e0b45dd5 by Claudio Cambra at 2024-10-17T10:50:10+00:00
macosx: Modify artwork controls bar button enablement via track selection change notification

Fixes issues with video view not being presented when reactivating a
video track and the artwork button not being properly reenabled. Seems
this was caused by the active video state being set before the track
selection object change is made

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


7 changed files:

- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/playlist/VLCPlayerController.h
- modules/gui/macosx/playlist/VLCPlayerController.m
- modules/gui/macosx/views/VLCTrackingView.h
- modules/gui/macosx/views/VLCTrackingView.m
- modules/gui/macosx/windows/controlsbar/VLCMainWindowControlsBar.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -26,7 +26,7 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
- at class VLCControlsBarCommon;
+ at class VLCMainWindowControlsBar;
 @class VLCDragDropView;
 @class VLCRoundedCornerTextField;
 @class VLCInputNodePathControl;
@@ -59,7 +59,7 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
 
 @property (readonly) NSView *libraryTargetView;
 
- at property (nonatomic, weak) IBOutlet VLCControlsBarCommon* controlsBar;
+ at property (nonatomic, weak) IBOutlet VLCMainWindowControlsBar *controlsBar;
 @property (readwrite, weak) IBOutlet NSLayoutConstraint *controlsBarHeightConstraint;
 @property (readwrite, weak) IBOutlet NSLayoutConstraint *videoViewBottomConstraint;
 @property (readwrite, weak) IBOutlet NSSegmentedControl *gridVsListSegmentedControl;
@@ -130,7 +130,7 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
 @property (readonly) VLCLibrarySortingMenuController *librarySortingMenuController;
 @property (readonly) VLCPlaylistController *playlistController;
 
-- (void)reopenVideoView;
+- (void)enableVideoPlaybackAppearance;
 - (void)disableVideoPlaybackAppearance;
 - (void)hideControlsBar;
 - (void)showControlsBar;


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -37,6 +37,7 @@
 #import "playlist/VLCPlayerController.h"
 #import "playlist/VLCPlaylistController.h"
 
+#import "library/VLCInputItem.h"
 #import "library/VLCLibraryController.h"
 #import "library/VLCLibraryCollectionViewItem.h"
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
@@ -74,8 +75,9 @@
 #import "views/VLCLoadingOverlayView.h"
 #import "views/VLCNoResultsLabel.h"
 #import "views/VLCRoundedCornerTextField.h"
+#import "views/VLCTrackingView.h"
 
-#import "windows/controlsbar/VLCControlsBarCommon.h"
+#import "windows/controlsbar/VLCMainWindowControlsBar.h"
 
 #import "windows/video/VLCVoutView.h"
 #import "windows/video/VLCVideoOutputProvider.h"
@@ -184,6 +186,10 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
                            selector:@selector(playerStateChanged:)
                                name:VLCPlayerStateChanged
                              object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(playerTrackSelectionChanged:)
+                               name:VLCPlayerTrackSelectionChanged
+                             object:nil];
 
     _libraryMediaSourceViewController = [[VLCLibraryMediaSourceViewController alloc] initWithLibraryWindow:self];
 
@@ -701,10 +707,21 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     }
 }
 
-// This handles reopening the video view when the user has closed it.
-- (void)reopenVideoView
+- (void)playerTrackSelectionChanged:(NSNotification *)notification
 {
-    [self enableVideoPlaybackAppearance];
+    VLCPlayerController * const playerController = self.playerController;
+    const BOOL videoTrackDisabled =
+        !playerController.videoTracksEnabled || !playerController.selectedVideoTrack.selected;
+    const BOOL audioTrackDisabled =
+        !playerController.audioTracksEnabled || !playerController.selectedAudioTrack.selected;
+    const BOOL currentItemIsAudio =
+        playerController.videoTracks.count == 0 && playerController.audioTracks.count > 0;
+    const BOOL artworkButtonDisabled =
+        (videoTrackDisabled && audioTrackDisabled) || (videoTrackDisabled && !currentItemIsAudio);
+    self.artworkButton.enabled = !artworkButtonDisabled;
+    self.artworkButton.hidden = artworkButtonDisabled;
+    self.controlsBar.thumbnailTrackingView.enabled = !artworkButtonDisabled;
+    self.controlsBar.thumbnailTrackingView.viewToHide.hidden = artworkButtonDisabled;
 }
 
 - (void)hideControlsBarImmediately
@@ -801,6 +818,17 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
 
 - (void)enableVideoPlaybackAppearance
 {
+    VLCPlayerController * const playerController = self.playerController;
+    const BOOL videoTrackDisabled =
+        !playerController.videoTracksEnabled || !playerController.selectedVideoTrack.selected;
+    const BOOL audioTrackDisabled =
+        !playerController.audioTracksEnabled || !playerController.selectedAudioTrack.selected;
+    const BOOL currentItemIsAudio =
+        playerController.videoTracks.count == 0 && playerController.audioTracks.count > 0;
+    if ((videoTrackDisabled && audioTrackDisabled) || (videoTrackDisabled && !currentItemIsAudio)) {
+        return;
+    }
+
     const BOOL isEmbedded = var_InheritBool(getIntf(), "embedded-video");
     if (!isEmbedded) {
         [self presentExternalWindows];


=====================================
modules/gui/macosx/playlist/VLCPlayerController.h
=====================================
@@ -768,6 +768,14 @@ extern const CGFloat VLCVolumeDefault;
  */
 @property (readonly, nullable) NSArray<VLCTrackMetaData *>* subtitleTracks;
 
+ at property (readonly) BOOL videoTracksEnabled;
+
+ at property (readonly) VLCTrackMetaData *selectedVideoTrack;
+
+ at property (readonly) BOOL audioTracksEnabled;
+
+ at property (readonly) VLCTrackMetaData *selectedAudioTrack;
+
 #pragma mark - video output properties
 
 /**


=====================================
modules/gui/macosx/playlist/VLCPlayerController.m
=====================================
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #import "VLCPlayerController.h"
+#include "vlc_player.h"
 
 #import <vlc_configuration.h>
 #import <vlc_url.h>
@@ -1473,6 +1474,41 @@ static int BossCallback(vlc_object_t *p_this,
     return [self tracksForCategory:SPU_ES];
 }
 
+- (VLCTrackMetaData *)selectedTrackMetadataOfCategory:(enum es_format_category_e)category
+{
+    vlc_player_Lock(_p_player);
+    const struct vlc_player_track * const p_track =
+        vlc_player_GetSelectedTrack(_p_player, category);
+    vlc_player_Unlock(_p_player);
+    return [[VLCTrackMetaData alloc] initWithTrackStructure:p_track];
+}
+
+- (BOOL)videoTracksEnabled
+{
+    vlc_player_Lock(_p_player);
+    const BOOL enabled = vlc_player_IsVideoEnabled(_p_player);
+    vlc_player_Unlock(_p_player);
+    return enabled;
+}
+
+- (VLCTrackMetaData *)selectedVideoTrack
+{
+    return [self selectedTrackMetadataOfCategory:VIDEO_ES];
+}
+
+- (BOOL)audioTracksEnabled
+{
+    vlc_player_Lock(_p_player);
+    const BOOL enabled = vlc_player_IsAudioEnabled(_p_player);
+    vlc_player_Unlock(_p_player);
+    return enabled;
+}
+
+- (VLCTrackMetaData *)selectedAudioTrack
+{
+    return [self selectedTrackMetadataOfCategory:AUDIO_ES];
+}
+
 - (void)programListChanged
 {
     [_defaultNotificationCenter postNotificationName:VLCPlayerProgramListChanged


=====================================
modules/gui/macosx/views/VLCTrackingView.h
=====================================
@@ -28,6 +28,7 @@ typedef void(^EnterExitBlock)(void);
 
 @interface VLCTrackingView : NSView
 
+ at property (readwrite) BOOL enabled;
 @property (readwrite) BOOL animatesTransition;
 @property (readwrite, assign, nullable) NSView *viewToHide; // Hide when mouse out
 @property (readwrite, assign, nullable) NSView *viewToShow; // Show when mouse out


=====================================
modules/gui/macosx/views/VLCTrackingView.m
=====================================
@@ -31,6 +31,40 @@
 
 @implementation VLCTrackingView
 
+- (instancetype)initWithFrame:(NSRect)frame
+{
+    self = [super initWithFrame:frame];
+    if (self) {
+        [self setupProperties];
+    }
+    return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+    if (self) {
+        [self setupProperties];
+    }
+    return self;
+}
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        [self setupProperties];
+    }
+    return self;
+}
+
+- (void)setupProperties
+{
+    _mouseIn = NO;
+    _animatesTransition = YES;
+    _enabled = YES;
+}
+
 - (void)performTransition
 {
     if (self.animatesTransition) {
@@ -63,6 +97,10 @@
 
 - (void)handleMouseEnter
 {
+    if (!self.enabled) {
+        return;
+    }
+
     _mouseIn = YES;
     [self performTransition];
     if (self.mouseEnteredBlock) {
@@ -72,6 +110,10 @@
 
 - (void)handleMouseExit
 {
+    if (!self.enabled) {
+        return;
+    }
+
     _mouseIn = NO;
     [self performTransition];
     if (self.mouseExitedBlock) {


=====================================
modules/gui/macosx/windows/controlsbar/VLCMainWindowControlsBar.m
=====================================
@@ -139,7 +139,7 @@
 
 - (IBAction)artworkButtonAction:(id)sender
 {
-    [VLCMain.sharedInstance.libraryWindow reopenVideoView];
+    [VLCMain.sharedInstance.libraryWindow enableVideoPlaybackAppearance];
 }
 
 #pragma mark -



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7ff000e6b4c0f8a24ab0e643b1bceb56e5c066b4...e0b45dd5eb946d127647704c5d09384fdaa23677

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7ff000e6b4c0f8a24ab0e643b1bceb56e5c066b4...e0b45dd5eb946d127647704c5d09384fdaa23677
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