[vlc-commits] [Git][videolan/vlc][master] 5 commits: macosx: Add property to player controller for whether current item is audio only
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Apr 21 10:13:22 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
138ea821 by Claudio Cambra at 2025-04-21T09:53:14+00:00
macosx: Add property to player controller for whether current item is audio only
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ba6a0a31 by Claudio Cambra at 2025-04-21T09:53:14+00:00
macosx: Only acquire video view for thumbnail video view if item is a video
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
72dfacea by Claudio Cambra at 2025-04-21T09:53:14+00:00
macosx: Extract live video artwork button view configuration to separate method
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
9b9afd4e by Claudio Cambra at 2025-04-21T09:53:14+00:00
macosx: When audio item is played, display thumbnail in control bar
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
97d91c1e by Claudio Cambra at 2025-04-21T09:53:14+00:00
macosx: Ensure acquired video view variable is nilified after returning view in library window
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4 changed files:
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/playqueue/VLCPlayerController.h
- modules/gui/macosx/playqueue/VLCPlayerController.m
- modules/gui/macosx/windows/video/VLCMainVideoViewController.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -188,6 +188,10 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
selector:@selector(playerStateChanged:)
name:VLCPlayerCurrentMediaItemChanged
object:nil];
+ [notificationCenter addObserver:self
+ selector:@selector(playerCurrentMediaItemChanged:)
+ name:VLCPlayerCurrentMediaItemChanged
+ object:nil];
[notificationCenter addObserver:self
selector:@selector(playerStateChanged:)
name:VLCPlayerStateChanged
@@ -428,6 +432,26 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
}
}
+- (void)playerCurrentMediaItemChanged:(NSNotification *)notification
+{
+ NSParameterAssert(notification);
+ VLCPlayerController * const controller = notification.object;
+ NSAssert(controller != nil,
+ @"Player current media item changed notification should have valid player controller");
+
+ // Live video playback in controls bar artwork button handling
+ if (self.splitViewController.mainVideoModeEnabled) {
+ return;
+ }
+
+ if (controller.currentMediaIsAudioOnly && _acquiredVideoView) {
+ [self.videoViewController returnVideoView:_acquiredVideoView];
+ _acquiredVideoView = nil;
+ } else if (!controller.currentMediaIsAudioOnly && _acquiredVideoView == nil) {
+ [self configureArtworkButtonLiveVideoView];
+ }
+}
+
- (void)playerTrackSelectionChanged:(NSNotification *)notification
{
[self updateArtworkButtonEnabledState];
@@ -453,6 +477,17 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
self.controlsBar.thumbnailTrackingView.viewToHide.hidden = artworkButtonDisabled;
}
+- (void)configureArtworkButtonLiveVideoView
+{
+ _acquiredVideoView = [self.videoViewController acquireVideoView];
+ if (_acquiredVideoView) {
+ [self.controlsBar.artworkImageView addSubview:_acquiredVideoView
+ positioned:NSWindowBelow
+ relativeTo:self.artworkButton];
+ [_acquiredVideoView applyConstraintsToFillSuperview];
+ }
+}
+
- (void)hideControlsBarImmediately
{
self.controlsBarHeightConstraint.constant = 0;
@@ -536,6 +571,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
if (_acquiredVideoView) {
[self.videoViewController returnVideoView:_acquiredVideoView];
+ _acquiredVideoView = nil;
}
[self presentVideoView];
@@ -562,12 +598,8 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
[self showControlsBarImmediately];
[self updateArtworkButtonEnabledState];
- _acquiredVideoView = [self.videoViewController acquireVideoView];
- if (_acquiredVideoView) {
- [self.controlsBar.artworkImageView addSubview:_acquiredVideoView
- positioned:NSWindowBelow
- relativeTo:self.artworkButton];
- [_acquiredVideoView applyConstraintsToFillSuperview];
+ if (!self.playQueueController.playerController.currentMediaIsAudioOnly) {
+ [self configureArtworkButtonLiveVideoView];
}
self.splitViewController.mainVideoModeEnabled = NO;
=====================================
modules/gui/macosx/playqueue/VLCPlayerController.h
=====================================
@@ -316,7 +316,7 @@ extern const CGFloat VLCVolumeDefault;
* @return the current media item, NULL if none
* @note it is the receiver's obligation to release the input item
*/
- at property (readonly, nullable) VLCInputItem * currentMedia;
+ at property (readonly, nullable) VLCInputItem *currentMedia;
/**
* returns the duration of the current media in vlc ticks
@@ -333,6 +333,12 @@ extern const CGFloat VLCVolumeDefault;
*/
@property (readonly, copy, nullable) NSString *nameOfCurrentMediaItem;
+/**
+ * returns whether the current playing item is an audio item or not
+ */
+
+ at property (readonly) BOOL currentMediaIsAudioOnly;
+
/**
* the current player state
* @return a value according to the vlc_player_state enum
=====================================
modules/gui/macosx/playqueue/VLCPlayerController.m
=====================================
@@ -800,6 +800,22 @@ static int BossCallback(vlc_object_t *p_this,
return name;
}
+- (BOOL)currentMediaIsAudioOnly
+{
+ NSURL * const currentItemUrl = self.URLOfCurrentMediaItem;
+ if (currentItemUrl == nil) {
+ return NO;
+ }
+
+ VLCMediaLibraryMediaItem * const mediaItem =
+ [VLCMediaLibraryMediaItem mediaItemForURL:currentItemUrl];
+ if (mediaItem != nil) {
+ return mediaItem.mediaType == VLC_ML_MEDIA_TYPE_AUDIO;
+ }
+
+ return self.videoTracks.count == 0 && self.audioTracks.count > 0;
+}
+
- (void)stateChanged:(enum vlc_player_state)state
{
/* instead of using vlc_player_GetState, we cache the state and provide it through a synthesized getter
=====================================
modules/gui/macosx/windows/video/VLCMainVideoViewController.m
=====================================
@@ -190,17 +190,7 @@
- (void)updateDecorativeViewVisibilityOnControllerChange:(VLCPlayerController *)controller
{
- VLCMediaLibraryMediaItem * const mediaItem =
- [VLCMediaLibraryMediaItem mediaItemForURL:controller.URLOfCurrentMediaItem];
-
- BOOL decorativeViewVisible = NO;
- if (mediaItem != nil) {
- decorativeViewVisible = mediaItem.mediaType == VLC_ML_MEDIA_TYPE_AUDIO;
- } else {
- VLCInputItem * const inputItem = controller.currentMedia;
- decorativeViewVisible = inputItem != nil && controller.videoTracks.count == 0;
- }
-
+ const BOOL decorativeViewVisible = controller.currentMediaIsAudioOnly;
NSView * const targetView = decorativeViewVisible ? self.audioDecorativeView : self.voutView;
self.voutContainingView.subviews = @[targetView];
[targetView applyConstraintsToFillSuperview];
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7caf2fdf0ad77a4989581f9830ad7d7a670b6cc0...97d91c1e78d63cbd1e89df7813f8cfdf7429ad9a
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7caf2fdf0ad77a4989581f9830ad7d7a670b6cc0...97d91c1e78d63cbd1e89df7813f8cfdf7429ad9a
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