Hopefully fixed metadata parsing for newly added tracks showing up in notifications
parent
90ac083705
commit
61c6cf3285
|
@ -49,6 +49,9 @@ typedef enum {
|
||||||
|
|
||||||
- (void)loadInfoForEntries:(NSArray *)entries;
|
- (void)loadInfoForEntries:(NSArray *)entries;
|
||||||
|
|
||||||
|
// To be dispatched on main thread only
|
||||||
|
- (void)syncLoadInfoForEntries:(NSArray *)entries;
|
||||||
|
|
||||||
- (NSArray *)acceptableFileTypes;
|
- (NSArray *)acceptableFileTypes;
|
||||||
- (NSArray *)acceptablePlaylistTypes; //Only m3u and pls saving
|
- (NSArray *)acceptablePlaylistTypes; //Only m3u and pls saving
|
||||||
- (NSArray *)acceptableContainerTypes;
|
- (NSArray *)acceptableContainerTypes;
|
||||||
|
|
|
@ -455,7 +455,13 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL
|
||||||
|
|
||||||
//Clear the selection
|
//Clear the selection
|
||||||
[playlistController setSelectionIndexes:[NSIndexSet indexSet]];
|
[playlistController setSelectionIndexes:[NSIndexSet indexSet]];
|
||||||
[self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:entries];
|
|
||||||
|
NSArray * firstEntry = [NSArray arrayWithObject:[entries objectAtIndex:0]];
|
||||||
|
NSMutableArray * restOfEntries = [NSMutableArray arrayWithArray:entries];
|
||||||
|
[restOfEntries removeObjectAtIndex:0];
|
||||||
|
|
||||||
|
[self performSelectorOnMainThread:@selector(syncLoadInfoForEntries:) withObject:firstEntry waitUntilDone:YES];
|
||||||
|
[self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:restOfEntries];
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,6 +469,52 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
|
||||||
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
|
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To be called on main thread only
|
||||||
|
- (void)syncLoadInfoForEntries:(NSArray *)entries
|
||||||
|
{
|
||||||
|
NSMutableIndexSet *update_indexes = [[NSMutableIndexSet alloc] init];
|
||||||
|
long i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (PlaylistEntry *pe in entries)
|
||||||
|
{
|
||||||
|
if ([pe metadataLoaded]) continue;
|
||||||
|
|
||||||
|
[update_indexes addIndex:pe.index];
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!i)
|
||||||
|
{
|
||||||
|
[self->playlistController updateTotalTime];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
for (PlaylistEntry *pe in entries)
|
||||||
|
{
|
||||||
|
NSMutableDictionary *entryInfo = [NSMutableDictionary dictionaryWithCapacity:20];
|
||||||
|
|
||||||
|
NSDictionary *entryProperties = [AudioPropertiesReader propertiesForURL:pe.URL];
|
||||||
|
if (entryProperties == nil)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
[entryInfo addEntriesFromDictionary:entryProperties];
|
||||||
|
[entryInfo addEntriesFromDictionary:[AudioMetadataReader metadataForURL:pe.URL]];
|
||||||
|
|
||||||
|
[pe setMetadata:entryInfo];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self->playlistController updateTotalTime];
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned long columns = [[[self->playlistView documentView] tableColumns] count];
|
||||||
|
[self->playlistView.documentView reloadDataForRowIndexes:update_indexes columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,columns-1)]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)loadInfoForEntries:(NSArray *)entries
|
- (void)loadInfoForEntries:(NSArray *)entries
|
||||||
{
|
{
|
||||||
NSMutableIndexSet *update_indexes = [[NSMutableIndexSet alloc] init];
|
NSMutableIndexSet *update_indexes = [[NSMutableIndexSet alloc] init];
|
||||||
|
|
Loading…
Reference in New Issue