vlc | branch: master | Felix Paul Kühne <[email protected]> | Wed Mar 27 17:51:09 2019 +0100| [6c0c4ffe555c9822cf01a6178d1033b70dab2218] | committer: Felix Paul Kühne
macosx/control bars: remove legacy playlist > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6c0c4ffe555c9822cf01a6178d1033b70dab2218 --- .../gui/macosx/coreinteraction/VLCInputManager.m | 5 +- modules/gui/macosx/main/VLCMain.m | 1 - .../windows/mainwindow/VLCControlsBarCommon.h | 7 +- .../windows/mainwindow/VLCControlsBarCommon.m | 57 ++++---- .../gui/macosx/windows/mainwindow/VLCMainWindow.h | 3 - .../gui/macosx/windows/mainwindow/VLCMainWindow.m | 37 ------ .../windows/mainwindow/VLCMainWindowControlsBar.h | 11 +- .../windows/mainwindow/VLCMainWindowControlsBar.m | 146 +++++++++++---------- .../macosx/windows/video/VLCVideoWindowCommon.m | 8 -- 9 files changed, 106 insertions(+), 169 deletions(-) diff --git a/modules/gui/macosx/coreinteraction/VLCInputManager.m b/modules/gui/macosx/coreinteraction/VLCInputManager.m index 5336633011..1688ba9499 100644 --- a/modules/gui/macosx/coreinteraction/VLCInputManager.m +++ b/modules/gui/macosx/coreinteraction/VLCInputManager.m @@ -241,11 +241,8 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, state = var_GetInteger(p_current_input, "state"); } - if (state == PLAYING_S) { - [[o_main mainWindow] setPause]; - } else { + if (state != PLAYING_S) { [[o_main mainMenu] setSubmenusEnabled: FALSE]; - [[o_main mainWindow] setPlay]; if (state == END_S || state == -1) { /* continue playback where you left off */ diff --git a/modules/gui/macosx/main/VLCMain.m b/modules/gui/macosx/main/VLCMain.m index cea62580a3..f4d07db9c9 100644 --- a/modules/gui/macosx/main/VLCMain.m +++ b/modules/gui/macosx/main/VLCMain.m @@ -307,7 +307,6 @@ static VLCMain *sharedInstance = nil; /* update the main window */ [[self mainWindow] updateWindow]; - [[self mainWindow] updateVolumeSlider]; // respect playlist-autostart if (var_GetBool(p_intf, "playlist-autostart")) { diff --git a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h index a82dcafd08..a99e9d8f35 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h +++ b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h @@ -1,7 +1,7 @@ /***************************************************************************** * VLCControlsBarCommon.h: MacOS X interface module ***************************************************************************** - * Copyright (C) 2012-2016 VLC authors and VideoLAN + * Copyright (C) 2012-2019 VLC authors and VideoLAN * * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org> * David Fuhrmann <david dot fuhrmann at googlemail dot com> @@ -63,9 +63,4 @@ - (IBAction)timeSliderAction:(id)sender; - (IBAction)fullscreen:(id)sender; -- (void)updateControls; -- (void)setPause; -- (void)setPlay; -- (void)setFullscreenState:(BOOL)b_fullscreen; - @end diff --git a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m index 8cb40daf69..82de0de77f 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m +++ b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m @@ -1,7 +1,7 @@ /***************************************************************************** * VLCControlsBarCommon.m: MacOS X interface module ***************************************************************************** - * Copyright (C) 2012-2016 VLC authors and VideoLAN + * Copyright (C) 2012-2019 VLC authors and VideoLAN * * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org> * David Fuhrmann <david dot fuhrmann at googlemail dot com> @@ -31,8 +31,6 @@ #import "playlist/VLCPlaylistController.h" #import "playlist/VLCPlayerController.h" -#import <vlc_playlist_legacy.h> - /***************************************************************************** * VLCControlsBarCommon * @@ -60,7 +58,11 @@ { [super awakeFromNib]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTimeSlider:) name:VLCPlayerTimeAndPositionChanged object:nil]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter addObserver:self selector:@selector(updateTimeSlider:) name:VLCPlayerTimeAndPositionChanged object:nil]; + [notificationCenter addObserver:self selector:@selector(playerStateUpdated:) name:VLCPlayerStateChanged object:nil]; + [notificationCenter addObserver:self selector:@selector(updatePlaybackControls:) name:VLCPlaylistCurrentItemChanged object:nil]; + [notificationCenter addObserver:self selector:@selector(fullscreenStateUpdated:) name:VLCPlayerFullscreenChanged object:nil]; _nativeFullscreenMode = var_InheritBool(getIntf(), "macosx-nativefullscreenmode"); @@ -321,34 +323,27 @@ input_item_Release(p_item); } -- (void)updateControls +- (void)playerStateUpdated:(NSNotification *)aNotification { - bool b_plmul = false; - bool b_seekable = false; - bool b_chapters = false; - - playlist_t * p_playlist = pl_Get(getIntf()); - - PL_LOCK; - b_plmul = playlist_CurrentSize(p_playlist) > 1; - PL_UNLOCK; - - input_thread_t * p_input = playlist_CurrentInput(p_playlist); - - if (p_input) { - /* seekable streams */ - b_seekable = var_GetBool(p_input, "can-seek"); - - /* chapters & titles */ - //FIXME! b_chapters = p_input->stream.i_area_nb > 1; - - input_Release(p_input); + VLCPlayerController *playerController = aNotification.object; + if (playerController.playerState == VLC_PLAYER_STATE_PLAYING) { + [self setPause]; + } else { + [self setPlay]; } +} + +- (void)updatePlaybackControls:(NSNotification *)aNotification +{ + VLCPlaylistController *playlistController = [[VLCMain sharedInstance] playlistController]; + bool b_seekable = playlistController.playerController.seekable; + // FIXME: re-add chapter navigation as needed + bool b_chapters = false; [self.timeSlider setEnabled: b_seekable]; - [self.forwardButton setEnabled: (b_seekable || b_plmul || b_chapters)]; - [self.backwardButton setEnabled: (b_seekable || b_plmul || b_chapters)]; + [self.forwardButton setEnabled: (b_seekable || playlistController.hasNextPlaylistItem || b_chapters)]; + [self.backwardButton setEnabled: (b_seekable || playlistController.hasPreviousPlaylistItem || b_chapters)]; } - (void)setPause @@ -367,10 +362,12 @@ self.playButton.accessibilityLabel = self.playButton.toolTip; } -- (void)setFullscreenState:(BOOL)b_fullscreen +- (void)fullscreenStateUpdated:(NSNotification *)aNotification { - if (!self.nativeFullscreenMode) - [self.fullscreenButton setState:b_fullscreen]; + if (!self.nativeFullscreenMode) { + VLCPlayerController *playerController = aNotification.object; + [self.fullscreenButton setState:playerController.fullscreen]; + } } @end diff --git a/modules/gui/macosx/windows/mainwindow/VLCMainWindow.h b/modules/gui/macosx/windows/mainwindow/VLCMainWindow.h index 21facc96b5..3c24627670 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCMainWindow.h +++ b/modules/gui/macosx/windows/mainwindow/VLCMainWindow.h @@ -113,9 +113,6 @@ typedef enum { - (void)updateTimeSlider; - (void)updateWindow; - (void)updateName; -- (void)setPause; -- (void)setPlay; -- (void)updateVolumeSlider; - (void)showFullscreenController; diff --git a/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m b/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m index 6085acf78c..fc6316a492 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m +++ b/modules/gui/macosx/windows/mainwindow/VLCMainWindow.m @@ -259,10 +259,6 @@ static const float f_min_window_height = 307.; [self resizeWindow]; } - /* update fs button to reflect state for next startup */ - if (var_InheritBool(pl_Get(getIntf()), "fullscreen")) - [self.controlsBar setFullscreenState:YES]; - /* restore split view */ f_lastLeftSplitViewWidth = 200; [[[VLCMain sharedInstance] mainMenu] updateSidebarMenuItem: ![_splitView isSubviewCollapsed:_splitViewLeft]]; @@ -633,11 +629,6 @@ static const float f_min_window_height = 307.; - (void)updateWindow { - [self.controlsBar updateControls]; - [[[VLCMain sharedInstance] voutProvider] updateControlsBarsUsingBlock:^(VLCControlsBarCommon *controlsBar) { - [controlsBar updateControls]; - }]; - bool b_seekable = false; playlist_t *p_playlist = pl_Get(getIntf()); @@ -655,29 +646,6 @@ static const float f_min_window_height = 307.; [self _updatePlaylistTitle]; } -- (void)setPause -{ - [self.controlsBar setPause]; - - [[[VLCMain sharedInstance] voutProvider] updateControlsBarsUsingBlock:^(VLCControlsBarCommon *controlsBar) { - [controlsBar setPause]; - }]; -} - -- (void)setPlay -{ - [self.controlsBar setPlay]; - - [[[VLCMain sharedInstance] voutProvider] updateControlsBarsUsingBlock:^(VLCControlsBarCommon *controlsBar) { - [controlsBar setPlay]; - }]; -} - -- (void)updateVolumeSlider -{ - [(VLCMainWindowControlsBar *)[self controlsBar] updateVolumeSlider]; -} - #pragma mark - #pragma mark Video Output handling @@ -708,11 +676,6 @@ static const float f_min_window_height = 307.; frameBeforePlayback = NSMakeRect(0, 0, 0, 0); - // update fs button to reflect state for next startup - if (var_InheritBool(getIntf(), "fullscreen") || var_GetBool(pl_Get(getIntf()), "fullscreen")) { - [self.controlsBar setFullscreenState:YES]; - } - [self makeFirstResponder: _playlistScrollView]; [[[VLCMain sharedInstance] voutProvider] updateWindowLevelForHelperWindows: NSNormalWindowLevel]; diff --git a/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.h b/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.h index 8df8996757..2296e3b77f 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.h +++ b/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.h @@ -1,7 +1,7 @@ /***************************************************************************** * ControlsBar.h: MacOS X interface module ***************************************************************************** - * Copyright (C) 2012-2016 VLC authors and VideoLAN + * Copyright (C) 2012-2019 VLC authors and VideoLAN * * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org> * David Fuhrmann <david dot fuhrmann at googlemail dot com> @@ -62,21 +62,12 @@ - (IBAction)volumeAction:(id)sender; - (IBAction)effects:(id)sender; -- (void)setRepeatOne; -- (void)setRepeatAll; -- (void)setRepeatOff; - (IBAction)repeat:(id)sender; -- (void)setShuffle; - - (IBAction)togglePlaylist:(id)sender; - (void)toggleEffectsButton; - (void)toggleJumpButtons; - (void)togglePlaymodeButtons; -- (void)updateVolumeSlider; -- (void)updateControls; - @end - diff --git a/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m b/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m index 29e96eb178..28fdaff477 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m +++ b/modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m @@ -30,8 +30,8 @@ #import "main/VLCMain.h" #import "menus/VLCMainMenu.h" #import "windows/mainwindow/VLCMainWindowControlsBar.h" - -#import <vlc_playlist_legacy.h> +#import "playlist/VLCPlaylistController.h" +#import "playlist/VLCPlayerController.h" /***************************************************************************** * VLCMainWindowControlsBar @@ -51,6 +51,8 @@ NSImage * _pressedShuffleImage; NSImage * _shuffleOnImage; NSImage * _pressedShuffleOnImage; + VLCPlaylistController *_playlistController; + VLCPlayerController *_playerController; } @end @@ -60,6 +62,15 @@ - (void)awakeFromNib { [super awakeFromNib]; + _playlistController = [[VLCMain sharedInstance] playlistController]; + _playerController = _playlistController.playerController; + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter addObserver:self selector:@selector(updatePlaybackControls:) name:VLCPlaylistCurrentItemChanged object:nil]; + [notificationCenter addObserver:self selector:@selector(updateVolumeSlider:) name:VLCPlayerVolumeChanged object:nil]; + [notificationCenter addObserver:self selector:@selector(updateVolumeSlider:) name:VLCPlayerMuteChanged object:nil]; + [notificationCenter addObserver:self selector:@selector(playbackOrderUpdated:) name:VLCPlaybackOrderChanged object:nil]; + [notificationCenter addObserver:self selector:@selector(playbackRepeatChanged:) name:VLCPlaybackRepeatChanged object:nil]; [self.stopButton setToolTip: _NS("Stop")]; self.stopButton.accessibilityLabel = self.stopButton.toolTip; @@ -281,18 +292,18 @@ - (IBAction)stop:(id)sender { - [[VLCCoreInteraction sharedInstance] stop]; + [_playlistController stopPlayback]; } // dynamically created next / prev buttons - (IBAction)prev:(id)sender { - [[VLCCoreInteraction sharedInstance] previous]; + [_playlistController playPreviousItem]; } - (IBAction)next:(id)sender { - [[VLCCoreInteraction sharedInstance] next]; + [_playlistController playNextItem]; } - (void)setRepeatOne @@ -315,48 +326,60 @@ - (IBAction)repeat:(id)sender { - vlc_value_t looping,repeating; - intf_thread_t * p_intf = getIntf(); - playlist_t * p_playlist = pl_Get(p_intf); - - var_Get(p_playlist, "repeat", &repeating); - var_Get(p_playlist, "loop", &looping); - - if (!repeating.b_bool && !looping.b_bool) { - /* was: no repeating at all, switching to Repeat One */ - [[VLCCoreInteraction sharedInstance] repeatOne]; - [self setRepeatOne]; - } - else if (repeating.b_bool && !looping.b_bool) { - /* was: Repeat One, switching to Repeat All */ - [[VLCCoreInteraction sharedInstance] repeatAll]; - [self setRepeatAll]; - } else { - /* was: Repeat All or bug in VLC, switching to Repeat Off */ - [[VLCCoreInteraction sharedInstance] repeatOff]; - [self setRepeatOff]; + enum vlc_playlist_playback_repeat repeatState = _playlistController.playbackRepeat; + switch (repeatState) { + case VLC_PLAYLIST_PLAYBACK_REPEAT_NONE: + /* was: no repeating at all, switching to Repeat One */ + _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT; + break; + case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT: + /* was: Repeat One, switching to Repeat All */ + _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL; + break; + + default: + /* was: Repeat All, switching to Repeat Off */ + _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE; + break; } } -- (void)setShuffle +- (void)playbackOrderUpdated:(NSNotification *)aNotification { - bool b_value; - playlist_t *p_playlist = pl_Get(getIntf()); - b_value = var_GetBool(p_playlist, "random"); - - if (b_value) { - [self.shuffleButton setImage: _shuffleOnImage]; - [self.shuffleButton setAlternateImage: _pressedShuffleOnImage]; - } else { + if (_playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL) { [self.shuffleButton setImage: _shuffleImage]; [self.shuffleButton setAlternateImage: _pressedShuffleImage]; + } else { + [self.shuffleButton setImage: _shuffleOnImage]; + [self.shuffleButton setAlternateImage: _pressedShuffleOnImage]; + } +} + +- (void)playbackRepeatChanged:(NSNotification *)aNotification +{ + enum vlc_playlist_playback_repeat repeatState = _playlistController.playbackRepeat; + switch (repeatState) { + case VLC_PLAYLIST_PLAYBACK_REPEAT_ALL: + [self setRepeatAll]; + break; + + case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT: + [self setRepeatOne]; + break; + + default: + [self setRepeatOff]; + break; } } - (IBAction)shuffle:(id)sender { - [[VLCCoreInteraction sharedInstance] shuffle]; - [self setShuffle]; + if (_playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL) { + _playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM; + } else { + _playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL; + } } - (IBAction)togglePlaylist:(id)sender @@ -382,57 +405,40 @@ #pragma mark - #pragma mark Extra updaters -- (void)updateVolumeSlider +- (void)updateVolumeSlider:(NSNotification *)aNotification { - int i_volume = [[VLCCoreInteraction sharedInstance] volume]; - BOOL b_muted = [[VLCCoreInteraction sharedInstance] mute]; + float f_volume = _playerController.volume; + BOOL b_muted = _playerController.mute; if (b_muted) - i_volume = 0; - - [self.volumeSlider setIntValue: i_volume]; + f_volume = 0.; - i_volume = (i_volume * 200) / AOUT_VOLUME_MAX; - NSString *volumeTooltip = [NSString stringWithFormat:_NS("Volume: %i %%"), i_volume]; + [self.volumeSlider setFloatValue: f_volume]; + NSString *volumeTooltip = [NSString stringWithFormat:_NS("Volume: %i %%"), f_volume * 100]; [self.volumeSlider setToolTip:volumeTooltip]; [self.volumeSlider setEnabled: !b_muted]; [self.volumeUpButton setEnabled: !b_muted]; } -- (void)updateControls +- (void)updatePlaybackControls:(NSNotification *)aNotification { - [super updateControls]; - bool b_input = false; - bool b_seekable = false; - bool b_plmul = false; - bool b_control = false; + bool b_seekable = _playerController.seekable; + bool b_control = _playerController.rateChangable; + // FIXME: re-add chapter navigation as needed bool b_chapters = false; - playlist_t * p_playlist = pl_Get(getIntf()); - - PL_LOCK; - b_plmul = playlist_CurrentSize(p_playlist) > 1; - PL_UNLOCK; - - input_thread_t * p_input = playlist_CurrentInput(p_playlist); - if ((b_input = (p_input != NULL))) { - /* seekable streams */ - b_seekable = var_GetBool(p_input, "can-seek"); - - /* check whether slow/fast motion is possible */ - b_control = var_GetBool(p_input, "can-rate"); - - /* chapters & titles */ - //FIXME! b_chapters = p_input->stream.i_area_nb > 1; - - input_Release(p_input); + input_item_t *p_item = _playerController.currentMedia; + b_input = p_item != NULL; + if (p_item) { + b_input = YES; + input_item_Release(p_item); } [self.stopButton setEnabled: b_input]; - [self.prevButton setEnabled: (b_seekable || b_plmul || b_chapters)]; - [self.nextButton setEnabled: (b_seekable || b_plmul || b_chapters)]; + [self.prevButton setEnabled: (b_seekable || _playlistController.hasPreviousPlaylistItem || b_chapters)]; + [self.nextButton setEnabled: (b_seekable || _playlistController.hasNextPlaylistItem || b_chapters)]; [[[VLCMain sharedInstance] mainMenu] setRateControlsEnabled: b_control]; } diff --git a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m index 94c371d90b..d6a2d06bd2 100644 --- a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m +++ b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m @@ -550,10 +550,6 @@ screen_rect = [screen frame]; - if (self.controlsBar) - [self.controlsBar setFullscreenState:YES]; - [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:YES]; - if (blackout_other_displays) [screen blackoutOtherScreens]; @@ -707,10 +703,6 @@ NSRect frame; BOOL blackout_other_displays = var_InheritBool(getIntf(), "macosx-black"); - if (self.controlsBar) - [self.controlsBar setFullscreenState:NO]; - [[[[VLCMain sharedInstance] mainWindow] controlsBar] setFullscreenState:NO]; - /* We always try to do so */ [NSScreen unblackoutScreens]; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
