Commit d641ed32 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

vpc: fix logic error which could lead to false-positive results for the audio-only property

parent 37fac1bc
...@@ -739,7 +739,7 @@ ...@@ -739,7 +739,7 @@
NSString *artist; NSString *artist;
NSString *albumName; NSString *albumName;
UIImage* artworkImage; UIImage* artworkImage;
BOOL mediaIsAudioOnly = YES; BOOL mediaIsAudioOnly = NO;
if (self.fileFromMediaLibrary) if (self.fileFromMediaLibrary)
item = self.fileFromMediaLibrary; item = self.fileFromMediaLibrary;
...@@ -758,34 +758,35 @@ ...@@ -758,34 +758,35 @@
/* MLKit knows better than us if this thing is audio only or not */ /* MLKit knows better than us if this thing is audio only or not */
mediaIsAudioOnly = [item isSupportedAudioFile]; mediaIsAudioOnly = [item isSupportedAudioFile];
if (mediaIsAudioOnly)
artworkImage = [VLCThumbnailsCache thumbnailForManagedObject:item];
} else { } else {
NSDictionary * metaDict = _mediaPlayer.media.metaDictionary; NSDictionary * metaDict = _mediaPlayer.media.metaDictionary;
/* this is a non file media, so we need to actually check if there is there is if (metaDict) {
* a video track included or not */ title = metaDict[VLCMetaInformationNowPlaying] ? metaDict[VLCMetaInformationNowPlaying] : metaDict[VLCMetaInformationTitle];
artist = metaDict[VLCMetaInformationArtist];
albumName = metaDict[VLCMetaInformationAlbum];
trackNumber = metaDict[VLCMetaInformationTrackNumber];
}
}
if (!mediaIsAudioOnly) {
/* either what we are playing is not a file known to MLKit or
* MLKit fails to acknowledge that it is audio-only.
* Either way, do a more expensive check to see if it is really audio-only */
NSArray *tracks = _mediaPlayer.media.tracksInformation; NSArray *tracks = _mediaPlayer.media.tracksInformation;
NSUInteger trackCount = tracks.count; NSUInteger trackCount = tracks.count;
mediaIsAudioOnly = YES;
for (NSUInteger x = 0 ; x < trackCount; x++) { for (NSUInteger x = 0 ; x < trackCount; x++) {
if ([[tracks[x] objectForKey:VLCMediaTracksInformationType] isEqualToString:VLCMediaTracksInformationTypeVideo]) { if ([[tracks[x] objectForKey:VLCMediaTracksInformationType] isEqualToString:VLCMediaTracksInformationTypeVideo]) {
mediaIsAudioOnly = NO; mediaIsAudioOnly = NO;
break; break;
} }
} }
if (metaDict) {
title = metaDict[VLCMetaInformationNowPlaying] ? metaDict[VLCMetaInformationNowPlaying] : metaDict[VLCMetaInformationTitle];
artist = metaDict[VLCMetaInformationArtist];
albumName = metaDict[VLCMetaInformationAlbum];
trackNumber = metaDict[VLCMetaInformationTrackNumber];
if (mediaIsAudioOnly)
artworkImage = [VLCThumbnailsCache thumbnailForManagedObject:item];
}
} }
if (mediaIsAudioOnly) { if (mediaIsAudioOnly) {
artworkImage = [VLCThumbnailsCache thumbnailForManagedObject:item];
if (artworkImage) { if (artworkImage) {
if (artist) if (artist)
title = [title stringByAppendingFormat:@" — %@", artist]; title = [title stringByAppendingFormat:@" — %@", artist];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment