Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
67966797 by Claudio Cambra at 2024-03-12T20:41:46+00:00
macosx: Remove unused randomItem and latestPartiallyPlayedItem properties in 
VLCLibraryHeroView

Signed-off-by: Claudio Cambra <develo...@claudiocambra.com>

- - - - -
93338b75 by Claudio Cambra at 2024-03-12T20:41:46+00:00
macosx: Fix empty hero view in home view caused by instantiating before model 
is ready

Signed-off-by: Claudio Cambra <develo...@claudiocambra.com>

- - - - -
07dfc0dd by Claudio Cambra at 2024-03-12T20:41:46+00:00
macosx: Stop resetting hero view once an item has been set

Signed-off-by: Claudio Cambra <develo...@claudiocambra.com>

- - - - -
1a49dbed by Claudio Cambra at 2024-03-12T20:41:46+00:00
macosx: Update represented item if it is updated in the backing model

Signed-off-by: Claudio Cambra <develo...@claudiocambra.com>

- - - - -
9f9ec520 by Claudio Cambra at 2024-03-12T20:41:46+00:00
macosx: Reset hero view if its represented item is deleted

Signed-off-by: Claudio Cambra <develo...@claudiocambra.com>

- - - - -


1 changed file:

- modules/gui/macosx/library/VLCLibraryHeroView.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryHeroView.m
=====================================
@@ -35,13 +35,6 @@
 
 #import "views/VLCImageView.h"
 
-@interface VLCLibraryHeroView ()
-
-@property (readonly) VLCMediaLibraryMediaItem *randomItem;
-@property (readonly) VLCMediaLibraryMediaItem *latestPartiallyPlayedItem;
-
-@end
-
 @implementation VLCLibraryHeroView
 
 + (instancetype)fromNibWithOwner:(id)owner
@@ -54,6 +47,7 @@
 - (void)awakeFromNib
 {
     self.largeImageView.contentGravity = 
VLCImageViewContentGravityResizeAspectFill;
+    [self connectItemUpdaters];
 }
 
 - (void)updateRepresentedItem
@@ -127,7 +121,8 @@
         return;
     }
 
-    NSLog(@"Could not find a food media item for hero view!");
+    NSLog(@"Could not find a good media item for hero view!");
+    [self connectForNewVideo];
 }
 
 - (IBAction)playRepresentedItem:(id)sender
@@ -135,4 +130,74 @@
     [self.representedItem play];
 }
 
+- (void)connectForNewVideo
+{
+    NSNotificationCenter * const notificationCenter = 
NSNotificationCenter.defaultCenter;
+    [notificationCenter addObserver:self
+                           selector:@selector(newVideosAvailable:)
+                               name:VLCLibraryModelVideoMediaListReset
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(newVideosAvailable:)
+                               name:VLCLibraryModelRecentsMediaListReset
+                             object:nil];
+}
+
+- (void)disconnectForNewVideo
+{
+    NSNotificationCenter * const notificationCenter = 
NSNotificationCenter.defaultCenter;
+    [notificationCenter removeObserver:self 
name:VLCLibraryModelVideoMediaListReset object:nil];
+    [notificationCenter removeObserver:self 
name:VLCLibraryModelRecentsMediaListReset object:nil];
+}
+
+- (void)newVideosAvailable:(NSNotification *)notification
+{
+    [self setOptimalRepresentedItem];
+    [self disconnectForNewVideo];
+}
+
+- (void)connectItemUpdaters
+{
+    NSNotificationCenter * const notificationCenter = 
NSNotificationCenter.defaultCenter;
+    [notificationCenter addObserver:self
+                           selector:@selector(itemUpdated:)
+                               name:VLCLibraryModelVideoMediaItemUpdated
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(itemUpdated:)
+                               name:VLCLibraryModelAudioMediaItemUpdated
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(itemDeleted:)
+                               name:VLCLibraryModelVideoMediaItemDeleted
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(itemDeleted:)
+                               name:VLCLibraryModelAudioMediaItemDeleted
+                             object:nil];
+}
+
+- (void)itemUpdated:(NSNotification *)notification
+{
+    VLCMediaLibraryMediaItem * const mediaItem = notification.object;
+    NSAssert(mediaItem != nil, @"Notification should contain a media item!");
+    if (mediaItem.libraryID != self.representedItem.item.libraryID) {
+        return;
+    }
+
+    VLCLibraryRepresentedItem * const item = [[VLCLibraryRepresentedItem 
alloc] initWithItem:mediaItem parentType:item.parentType];
+    self.representedItem = item;
+}
+
+- (void)itemDeleted:(NSNotification *)notification
+{
+    VLCMediaLibraryMediaItem * const mediaItem = notification.object;
+    NSAssert(mediaItem != nil, @"Notification should contain a media item!");
+    if (mediaItem.libraryID != self.representedItem.item.libraryID) {
+        return;
+    }
+
+    [self setOptimalRepresentedItem];
+}
+
 @end



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/aeac0654dfdc307a480851e63728b484daa3057b...9f9ec52016207f36f9050da4180a86be63ae7b2a

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/aeac0654dfdc307a480851e63728b484daa3057b...9f9ec52016207f36f9050da4180a86be63ae7b2a
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to