|
|
|
@ -24,6 +24,7 @@ |
|
|
|
#import "VLCMainWindowControlsBar.h" |
|
|
|
#import "VLCControlsBarCommon.h" |
|
|
|
|
|
|
|
#import "extensions/NSColor+VLCAdditions.h" |
|
|
|
#import "extensions/NSString+Helpers.h" |
|
|
|
|
|
|
|
#import "library/VLCInputItem.h" |
|
|
|
@ -46,6 +47,12 @@ |
|
|
|
|
|
|
|
@interface VLCMainWindowControlsBar() |
|
|
|
{ |
|
|
|
NSImage *_repeatOffImage; |
|
|
|
NSImage *_repeatAllImage; |
|
|
|
NSImage *_repeatOneImage; |
|
|
|
NSImage *_shuffleOffImage; |
|
|
|
NSImage *_shuffleOnImage; |
|
|
|
|
|
|
|
VLCPlaylistController *_playlistController; |
|
|
|
VLCPlayerController *_playerController; |
|
|
|
} |
|
|
|
@ -60,8 +67,35 @@ |
|
|
|
_playerController = _playlistController.playerController; |
|
|
|
|
|
|
|
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; |
|
|
|
[notificationCenter addObserver:self selector:@selector(updatePlaybackControls:) name:VLCPlaylistCurrentItemChanged object:nil]; |
|
|
|
[notificationCenter addObserver:self selector:@selector(playbackStateChanged:) name:VLCPlayerStateChanged object:nil]; |
|
|
|
[notificationCenter addObserver:self |
|
|
|
selector:@selector(updatePlaybackControls:) |
|
|
|
name:VLCPlaylistCurrentItemChanged |
|
|
|
object:nil]; |
|
|
|
[notificationCenter addObserver:self |
|
|
|
selector:@selector(playbackStateChanged:) |
|
|
|
name:VLCPlayerStateChanged |
|
|
|
object:nil]; |
|
|
|
[notificationCenter addObserver:self |
|
|
|
selector:@selector(shuffleStateUpdated:) |
|
|
|
name:VLCPlaybackOrderChanged |
|
|
|
object:nil]; |
|
|
|
[notificationCenter addObserver:self |
|
|
|
selector:@selector(repeatStateUpdated:) |
|
|
|
name:VLCPlaybackRepeatChanged |
|
|
|
object:nil]; |
|
|
|
|
|
|
|
_repeatAllImage = [NSImage imageNamed:@"repeatAll"]; |
|
|
|
_repeatOffImage = [NSImage imageNamed:@"repeatOff"]; |
|
|
|
_repeatOneImage = [NSImage imageNamed:@"repeatOne"]; |
|
|
|
|
|
|
|
_shuffleOffImage = [NSImage imageNamed:@"shuffleOff"]; |
|
|
|
_shuffleOnImage = [NSImage imageNamed:@"shuffleOn"]; |
|
|
|
|
|
|
|
self.repeatButton.action = @selector(repeatAction:); |
|
|
|
self.shuffleButton.action = @selector(shuffleAction:); |
|
|
|
|
|
|
|
[self repeatStateUpdated:nil]; |
|
|
|
[self shuffleStateUpdated:nil]; |
|
|
|
|
|
|
|
[self.stopButton setToolTip: _NS("Stop")]; |
|
|
|
self.stopButton.accessibilityLabel = self.stopButton.toolTip; |
|
|
|
@ -122,6 +156,32 @@ |
|
|
|
[[VLCMain sharedInstance].libraryWindow reopenVideoView]; |
|
|
|
} |
|
|
|
|
|
|
|
- (IBAction)shuffleAction:(id)sender |
|
|
|
{ |
|
|
|
if (_playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL) { |
|
|
|
_playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM; |
|
|
|
} else { |
|
|
|
_playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
- (IBAction)repeatAction:(id)sender |
|
|
|
{ |
|
|
|
enum vlc_playlist_playback_repeat currentRepeatState = _playlistController.playbackRepeat; |
|
|
|
switch (currentRepeatState) { |
|
|
|
case VLC_PLAYLIST_PLAYBACK_REPEAT_ALL: |
|
|
|
_playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE; |
|
|
|
break; |
|
|
|
case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT: |
|
|
|
_playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL; |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
_playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#pragma mark - |
|
|
|
#pragma mark Extra updaters |
|
|
|
|
|
|
|
@ -146,6 +206,40 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
- (void)repeatStateUpdated:(NSNotification *)aNotification |
|
|
|
{ |
|
|
|
enum vlc_playlist_playback_repeat currentRepeatState = _playlistController.playbackRepeat; |
|
|
|
|
|
|
|
switch (currentRepeatState) { |
|
|
|
case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT: |
|
|
|
self.repeatButton.image = _repeatOneImage; |
|
|
|
break; |
|
|
|
case VLC_PLAYLIST_PLAYBACK_REPEAT_ALL: |
|
|
|
self.repeatButton.image = _repeatAllImage; |
|
|
|
break; |
|
|
|
case VLC_PLAYLIST_PLAYBACK_REPEAT_NONE: |
|
|
|
default: |
|
|
|
self.repeatButton.image = _repeatOffImage; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (@available(macOS 11.0, *)) { |
|
|
|
self.repeatButton.contentTintColor = currentRepeatState == VLC_PLAYLIST_PLAYBACK_REPEAT_NONE ? |
|
|
|
nil : [NSColor VLCAccentColor]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
- (void)shuffleStateUpdated:(NSNotification *)aNotification |
|
|
|
{ |
|
|
|
self.shuffleButton.image = _playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL ? |
|
|
|
_shuffleOffImage : _shuffleOnImage; |
|
|
|
|
|
|
|
if (@available(macOS 11.0, *)) { |
|
|
|
self.shuffleButton.contentTintColor = _playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL ? |
|
|
|
nil : [NSColor VLCAccentColor]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
- (void)updatePlaybackControls:(NSNotification *)aNotification |
|
|
|
{ |
|
|
|
bool b_seekable = _playerController.seekable; |
|
|
|
|