mirror of
https://code.videolan.org/videolan/vlc
synced 2024-08-18 23:45:06 +02:00
macosx: allow simultanous video or SPU track selection
Press the alt key to select more than 1 key. This also fixes the state display in main menu when the selection changes.
This commit is contained in:
parent
22f11eeb11
commit
35d0d00ff6
@ -186,6 +186,10 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
|
||||
selector:@selector(updateTrackHandlingMenus:)
|
||||
name:VLCPlayerTrackListChanged
|
||||
object:nil];
|
||||
[notificationCenter addObserver:self
|
||||
selector:@selector(updateTrackHandlingMenus:)
|
||||
name:VLCPlayerTrackSelectionChanged
|
||||
object:nil];
|
||||
[notificationCenter addObserver:self
|
||||
selector:@selector(updateTitleAndChapterMenus:)
|
||||
name:VLCPlayerTitleListChanged
|
||||
@ -906,6 +910,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
|
||||
category:(enum es_format_category_e)category
|
||||
{
|
||||
[menu removeAllItems];
|
||||
BOOL itemSelected = NO;
|
||||
|
||||
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:_NS("Disable")
|
||||
action:@selector(unselectTrackCategory:)
|
||||
@ -923,14 +928,25 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
|
||||
[menuItem setTarget:self];
|
||||
[menuItem setRepresentedObject:metaDataItem];
|
||||
[menuItem setEnabled:YES];
|
||||
[menuItem setState:metaDataItem.selected ? NSOnState : NSOffState];
|
||||
if (metaDataItem.selected) {
|
||||
itemSelected = YES;
|
||||
[menuItem setState:NSOnState];
|
||||
} else {
|
||||
[menuItem setState:NSOffState];
|
||||
}
|
||||
[menu addItem:menuItem];
|
||||
}
|
||||
|
||||
/* select the "Disabled" item in case no track is selected */
|
||||
if (!itemSelected) {
|
||||
[menu.itemArray.firstObject setState:NSOnState];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)selectTrack:(NSMenuItem *)sender
|
||||
{
|
||||
[_playerController selectTrack:[sender representedObject]];
|
||||
NSEvent *currentEvent = [NSApp currentEvent];
|
||||
[_playerController selectTrack:[sender representedObject] exclusively:!(currentEvent.modifierFlags & NSAlternateKeyMask)];
|
||||
}
|
||||
|
||||
- (void)unselectTrackCategory:(NSMenuItem *)sender
|
||||
|
@ -716,10 +716,12 @@ extern const CGFloat VLCVolumeDefault;
|
||||
|
||||
/**
|
||||
* select a track
|
||||
* @param the track to select
|
||||
* @param indicate whether multiple tracks may be played (video and SPU only)
|
||||
* @note since tracks are unique, you do not need to specify the type
|
||||
* @note listen to VLCTrackSelectionChanged to be notified once the change occured
|
||||
*/
|
||||
- (void)selectTrack:(VLCTrackMetaData *)track;
|
||||
- (void)selectTrack:(VLCTrackMetaData *)track exclusively:(BOOL)exclusiveSelection;
|
||||
|
||||
/**
|
||||
* unselect a track
|
||||
|
@ -1387,10 +1387,11 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
|
||||
[_defaultNotificationCenter postNotificationName:VLCPlayerTrackListChanged object:nil];
|
||||
}
|
||||
|
||||
- (void)selectTrack:(VLCTrackMetaData *)track
|
||||
- (void)selectTrack:(VLCTrackMetaData *)track exclusively:(BOOL)exclusiveSelection
|
||||
{
|
||||
vlc_player_Lock(_p_player);
|
||||
vlc_player_SelectEsId(_p_player, track.esID, VLC_PLAYER_SELECT_EXCLUSIVE);
|
||||
const enum es_format_category_e formatCategory = vlc_es_id_GetCat(track.esID);
|
||||
vlc_player_SelectEsId(_p_player, track.esID, (formatCategory == AUDIO_ES || exclusiveSelection) ? VLC_PLAYER_SELECT_EXCLUSIVE : VLC_PLAYER_SELECT_SIMULTANEOUS);
|
||||
vlc_player_Unlock(_p_player);
|
||||
}
|
||||
|
||||
@ -1767,7 +1768,7 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@: name: %@", [VLCTrackMetaData className], self.name];
|
||||
return [NSString stringWithFormat:@"%@: name: %@, selected: %i", [VLCTrackMetaData className], self.name, self.selected];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user