diff --git a/RedBookPlayer/PlayerView.xaml.cs b/RedBookPlayer/PlayerView.xaml.cs
index 411b101..f5ac532 100644
--- a/RedBookPlayer/PlayerView.xaml.cs
+++ b/RedBookPlayer/PlayerView.xaml.cs
@@ -220,6 +220,43 @@ namespace RedBookPlayer
};
}
+ ///
+ /// Load an image from the path
+ ///
+ /// Path to the image to load
+ 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();
+ });
+ }
+ }
+
///
/// Update the UI with the most recent information from the Player
///
@@ -257,35 +294,7 @@ namespace RedBookPlayer
if (path == null)
return;
- 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();
- });
- }
+ LoadImage(path);
}
public void PlayButton_Click(object sender, RoutedEventArgs e) => Player.Play();