[vlc-commits] [Git][videolan/vlc][master] 5 commits: macosx: Remove unused randomItem and latestPartiallyPlayedItem properties in VLCLibraryHeroView
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Tue Mar 12 20:59:40 UTC 2024
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 <developer at 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 <developer at 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 <developer at 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 <developer at 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 <developer at 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"
- at interface VLCLibraryHeroView ()
-
- at property (readonly) VLCMediaLibraryMediaItem *randomItem;
- at property (readonly) VLCMediaLibraryMediaItem *latestPartiallyPlayedItem;
-
- at 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
More information about the vlc-commits
mailing list