mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Separate loading into a new method
This commit is contained in:
@@ -220,6 +220,43 @@ namespace RedBookPlayer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load an image from the path
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to the image to load</param>
|
||||||
|
private async void LoadImage(string path)
|
||||||
|
{
|
||||||
|
bool result = await Task.Run(() =>
|
||||||
|
{
|
||||||
|
var image = new AaruFormat();
|
||||||
|
var filter = new ZZZNoFilter();
|
||||||
|
filter.Open(path);
|
||||||
|
image.Open(filter);
|
||||||
|
|
||||||
|
if(IsPlayableImage(image))
|
||||||
|
{
|
||||||
|
PlayableDisc.Init(image, App.Settings.AutoPlay);
|
||||||
|
if(PlayableDisc.Initialized)
|
||||||
|
{
|
||||||
|
Player.Init(PlayableDisc, App.Settings.AutoPlay);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
MainWindow.Instance.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the UI with the most recent information from the Player
|
/// Update the UI with the most recent information from the Player
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -257,35 +294,7 @@ namespace RedBookPlayer
|
|||||||
if (path == null)
|
if (path == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool result = await Task.Run(() =>
|
LoadImage(path);
|
||||||
{
|
|
||||||
var image = new AaruFormat();
|
|
||||||
var filter = new ZZZNoFilter();
|
|
||||||
filter.Open(path);
|
|
||||||
image.Open(filter);
|
|
||||||
|
|
||||||
if (IsPlayableImage(image))
|
|
||||||
{
|
|
||||||
PlayableDisc.Init(image, App.Settings.AutoPlay);
|
|
||||||
if (PlayableDisc.Initialized)
|
|
||||||
{
|
|
||||||
Player.Init(PlayableDisc, App.Settings.AutoPlay);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
||||||
{
|
|
||||||
MainWindow.Instance.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayButton_Click(object sender, RoutedEventArgs e) => Player.Play();
|
public void PlayButton_Click(object sender, RoutedEventArgs e) => Player.Play();
|
||||||
|
|||||||
Reference in New Issue
Block a user