Browse Source

macosx: Ensure we get the current playing item in control bar

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
pull/162/head
Claudio Cambra 3 years ago
committed by Jean-Baptiste Kempf
parent
commit
b94a2c66d2
  1. 17
      modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
  2. 17
      modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m

17
modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m

@ -26,6 +26,8 @@
#import "extensions/NSString+Helpers.h"
#import "main/VLCMain.h"
#import "playlist/VLCPlaylistController.h"
#import "playlist/VLCPlaylistItem.h"
#import "playlist/VLCPlaylistModel.h"
#import "playlist/VLCPlayerController.h"
#import "library/VLCInputItem.h"
@ -423,7 +425,20 @@
- (void)updateCurrentItemDisplayControls:(NSNotification *)aNotification
{
VLCInputItem * const inputItem = _playerController.currentMedia;
// If we use the playlist's currentPlayingItem we will get the same item we had before.
// Let's instead grab the playlist item from the playlist model, as we know this is
// updated before the VLCPlaylistCurrentItemChanged notification is sent out
const size_t currentPlaylistIndex = _playlistController.currentPlaylistIndex;
if (currentPlaylistIndex < 0) {
return;
}
VLCPlaylistItem * const currentPlayingItem = [_playlistController.playlistModel playlistItemAtIndex:currentPlaylistIndex];
if (!currentPlayingItem) {
return;
}
VLCInputItem * const inputItem = currentPlayingItem.inputItem;
if (!inputItem) {
return;
}

17
modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m

@ -33,6 +33,8 @@
#import "main/VLCMain.h"
#import "playlist/VLCPlaylistController.h"
#import "playlist/VLCPlaylistItem.h"
#import "playlist/VLCPlaylistModel.h"
#import "playlist/VLCPlayerController.h"
#import "views/VLCTimeField.h"
@ -196,7 +198,20 @@
{
[super updateCurrentItemDisplayControls:aNotification];
VLCInputItem * const inputItem = _playerController.currentMedia;
// If we use the playlist's currentPlayingItem we will get the same item we had before.
// Let's instead grab the playlist item from the playlist model, as we know this is
// updated before the VLCPlaylistCurrentItemChanged notification is sent out
const size_t currentPlaylistIndex = _playlistController.currentPlaylistIndex;
if (currentPlaylistIndex < 0) {
return;
}
VLCPlaylistItem * const currentPlayingItem = [_playlistController.playlistModel playlistItemAtIndex:currentPlaylistIndex];
if (!currentPlayingItem) {
return;
}
VLCInputItem * const inputItem = currentPlayingItem.inputItem;
if (!inputItem) {
return;
}

Loading…
Cancel
Save