mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 19:02:19 -05:00
retrieve cover art from directory if there's no embedded art
This commit is contained in:
parent
ebc97da0a5
commit
2e0a1ceb88
2 changed files with 35 additions and 6 deletions
|
@ -294,6 +294,30 @@ namespace FRESHMusicPlayer
|
||||||
TrackingHandler = null;
|
TrackingHandler = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public MemoryStream GetCoverArtFromDirectory()
|
||||||
|
{
|
||||||
|
bool FileIsImage(string path)
|
||||||
|
{
|
||||||
|
if (Path.GetExtension(path) == ".png" || Path.GetExtension(path) == ".jpg" || Path.GetExtension(path) == ".jpeg") return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
var currentDirectory = Path.GetDirectoryName(Player.FilePath);
|
||||||
|
foreach (var file in Directory.EnumerateFiles(currentDirectory))
|
||||||
|
{
|
||||||
|
if (Path.GetFileNameWithoutExtension(file).ToUpper() == "COVER" ||
|
||||||
|
Path.GetFileNameWithoutExtension(file).ToUpper() == "ARTWORK" ||
|
||||||
|
Path.GetFileNameWithoutExtension(file).ToUpper() == "FRONT" ||
|
||||||
|
Path.GetFileNameWithoutExtension(file).ToUpper() == "BACK" ||
|
||||||
|
Path.GetFileNameWithoutExtension(file).ToUpper() == Player.FilePath)
|
||||||
|
{
|
||||||
|
if (FileIsImage(file))
|
||||||
|
{
|
||||||
|
return new MemoryStream(File.ReadAllBytes(file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
#region Tabs
|
#region Tabs
|
||||||
private void ChangeTabs(SelectedMenu tab, string search = null)
|
private void ChangeTabs(SelectedMenu tab, string search = null)
|
||||||
{
|
{
|
||||||
|
@ -363,8 +387,17 @@ namespace FRESHMusicPlayer
|
||||||
UpdatePlayButtonState();
|
UpdatePlayButtonState();
|
||||||
if (CurrentTrack.EmbeddedPictures.Count == 0)
|
if (CurrentTrack.EmbeddedPictures.Count == 0)
|
||||||
{
|
{
|
||||||
CoverArtBox.Source = null;
|
var file = GetCoverArtFromDirectory();
|
||||||
SetCoverArtVisibility(false);
|
if (file != null)
|
||||||
|
{
|
||||||
|
CoverArtBox.Source = BitmapFrame.Create(file, BitmapCreateOptions.None, BitmapCacheOption.None);
|
||||||
|
SetCoverArtVisibility(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CoverArtBox.Source = null;
|
||||||
|
SetCoverArtVisibility(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,10 +72,6 @@ namespace FRESHMusicPlayer.Pages
|
||||||
General_UpdateModeCombo.SelectedIndex = (int)UpdateCombo.Prompt;
|
General_UpdateModeCombo.SelectedIndex = (int)UpdateCombo.Prompt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
foreach (var plugin in (Application.Current.MainWindow as MainWindow)?.PluginManager.Plugins)
|
|
||||||
{
|
|
||||||
Plugins_LoadedPluginsListBox.Items.Add(new TextBlock { Text = $"{plugin.Name} - {plugin.Description}\nby {plugin.Author}", TextWrapping = TextWrapping.Wrap});
|
|
||||||
}
|
|
||||||
pageInitialized = true;
|
pageInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue