Skip to content

Commit

Permalink
Provide mechanism to avoid system default thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwun committed Feb 18, 2020
1 parent 2e335f0 commit 30ad383
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
10 changes: 4 additions & 6 deletions Reborn-Zune-MusicLibraryService/DataBase/DataBaseEngine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Reborn_Zune_MusicLibraryEFCoreModel;
using Reborn_Zune_MusicLibraryService.DataModel;
using Reborn_Zune_MusicLibraryService.Utility;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -45,7 +46,7 @@ public static async Task Add(StorageFile File)
Debug.WriteLine(File.Name + " Music meta data start retreiving");


var thumbnail = await File.GetThumbnailAsync(ThumbnailMode.MusicView, 100, ThumbnailOptions.ReturnOnlyIfCached);
var thumbnail = await File.GetThumbnailAsync(ThumbnailMode.MusicView, 100, ThumbnailOptions.UseCurrentScale);
var properties = await File.Properties.GetMusicPropertiesAsync();

var path = File.Path;
Expand Down Expand Up @@ -250,16 +251,13 @@ public static bool PlaylistNameAvailable(string playlistName)
}
private static async Task<byte[]> ConvertThumbnailToBytesAsync(StorageItemThumbnail thumbnail)
{
if (thumbnail == null)
{
return new byte[0];
}
byte[] result = new byte[thumbnail.Size];
using (var reader = new DataReader(thumbnail))
{
await reader.LoadAsync((uint)thumbnail.Size);
reader.ReadBytes(result);
return result;
string base64ImageString = Convert.ToBase64String(result);
return base64ImageString == Utilities.NULL_THUMBNAIL_BASE64_STRING ? new byte[0] : result;
}
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<Compile Include="DataModel\MLThumbnailModel.cs" />
<Compile Include="MusicLibraryService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utility\Utility.cs" />
<EmbeddedResource Include="Properties\MusicLibrary.rd.xml" />
</ItemGroup>
<ItemGroup>
Expand Down
14 changes: 14 additions & 0 deletions Reborn-Zune-MusicLibraryService/Utility/Utility.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Reborn-Zune/Reborn-Zune.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<PackageCertificateThumbprint>0FB468EE92880A98E7F2BE947E06EB6F762F8B87</PackageCertificateThumbprint>
<PackageCertificateKeyFile>Reborn-Zune_StoreKey.pfx</PackageCertificateKeyFile>
<PackageCertificateKeyFile>
</PackageCertificateKeyFile>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppInstallerUpdateFrequency>0</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
Expand Down

0 comments on commit 30ad383

Please sign in to comment.