diff --git a/README.md b/README.md index a8c710e..7683f50 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ | **Space** | Toggle Play / Pause | | **Esc** | Stop Playback | | **~** | Eject | +| **Page Up** | Next Disc | +| **Page Down** | Previous Disc | | **→** | Next Track | | **←** | Previous Track | | **]** | Next Index | diff --git a/RedBookPlayer.GUI/ViewModels/MainViewModel.cs b/RedBookPlayer.GUI/ViewModels/MainViewModel.cs index c3a2a0e..06d6099 100644 --- a/RedBookPlayer.GUI/ViewModels/MainViewModel.cs +++ b/RedBookPlayer.GUI/ViewModels/MainViewModel.cs @@ -75,6 +75,18 @@ namespace RedBookPlayer.GUI.ViewModels PlayerView?.ViewModel?.ExecuteEject(); } + // Next Disc + else if(e.Key == App.Settings.NextDiscKey) + { + PlayerView?.ViewModel?.ExecuteNextDisc(); + } + + // Previous Disc + else if(e.Key == App.Settings.PreviousDiscKey) + { + PlayerView?.ViewModel?.ExecutePreviousDisc(); + } + // Next Track else if(e.Key == App.Settings.NextTrackKey || e.Key == Key.MediaNextTrack) { diff --git a/RedBookPlayer.GUI/ViewModels/PlayerViewModel.cs b/RedBookPlayer.GUI/ViewModels/PlayerViewModel.cs index df91f2f..3a15593 100644 --- a/RedBookPlayer.GUI/ViewModels/PlayerViewModel.cs +++ b/RedBookPlayer.GUI/ViewModels/PlayerViewModel.cs @@ -44,6 +44,15 @@ namespace RedBookPlayer.GUI.ViewModels #region OpticalDisc Passthrough + /// + /// Path to the disc image + /// + public string ImagePath + { + get => _imagePath; + private set => this.RaiseAndSetIfChanged(ref _imagePath, value); + } + /// /// Current track number /// @@ -159,6 +168,7 @@ namespace RedBookPlayer.GUI.ViewModels /// public ulong TotalTime => _player.TotalTime; + private string _imagePath; private int _currentTrackNumber; private ushort _currentTrackIndex; private ushort _currentTrackSession; @@ -274,6 +284,16 @@ namespace RedBookPlayer.GUI.ViewModels /// public ReactiveCommand EjectCommand { get; } + /// + /// Command for moving to the next disc + /// + public ReactiveCommand NextDiscCommand { get; } + + /// + /// Command for moving to the previous disc + /// + public ReactiveCommand PreviousDiscCommand { get; } + /// /// Command for moving to the next track /// @@ -359,6 +379,8 @@ namespace RedBookPlayer.GUI.ViewModels TogglePlayPauseCommand = ReactiveCommand.Create(ExecuteTogglePlayPause); StopCommand = ReactiveCommand.Create(ExecuteStop); EjectCommand = ReactiveCommand.Create(ExecuteEject); + NextDiscCommand = ReactiveCommand.Create(ExecuteNextDisc); + PreviousDiscCommand = ReactiveCommand.Create(ExecutePreviousDisc); NextTrackCommand = ReactiveCommand.Create(ExecuteNextTrack); PreviousTrackCommand = ReactiveCommand.Create(ExecutePreviousTrack); NextIndexCommand = ReactiveCommand.Create(ExecuteNextIndex); @@ -819,8 +841,17 @@ namespace RedBookPlayer.GUI.ViewModels }); } + ImagePath = _player.ImagePath; Initialized = _player.Initialized; + if (!string.IsNullOrWhiteSpace(ImagePath) && Initialized) + { + Dispatcher.UIThread.InvokeAsync(() => + { + App.MainWindow.Title = "RedBookPlayer - " + ImagePath.Split('/').Last().Split('\\').Last(); + }); + } + CurrentDisc = _player.CurrentDisc; CurrentTrackNumber = _player.CurrentTrackNumber; CurrentTrackIndex = _player.CurrentTrackIndex; diff --git a/RedBookPlayer.GUI/Views/PlayerView.xaml b/RedBookPlayer.GUI/Views/PlayerView.xaml index c599c86..a396c2a 100644 --- a/RedBookPlayer.GUI/Views/PlayerView.xaml +++ b/RedBookPlayer.GUI/Views/PlayerView.xaml @@ -103,7 +103,8 @@ 4CH HIDDEN HIDDEN - + + \ No newline at end of file diff --git a/RedBookPlayer.GUI/Views/SettingsWindow.xaml b/RedBookPlayer.GUI/Views/SettingsWindow.xaml index 4000a8a..8c42316 100644 --- a/RedBookPlayer.GUI/Views/SettingsWindow.xaml +++ b/RedBookPlayer.GUI/Views/SettingsWindow.xaml @@ -58,120 +58,144 @@ - - - - - - - - - - - - - - - - - - - - - - - + - Load Image - + + Load Image + + - Save Track(s) - + + Save Track(s) + + - Toggle Play/Pause - + + Toggle Play/Pause + + - Stop Playback - + + Stop Playback + + - Eject Disc - + + Eject Disc + + + + + + Next Disc + + + + + + Previous Disc + + - Next Track - + + Next Track + + - Previous Track - + + Previous Track + + - Next Index - + + Next Index + + - Previous Index - + + Previous Index + + - Fast-Forward - + + Fast-Forward + + - Rewind - + + Rewind + + - Volume Up - + + Volume Up + + - Volume Down - + + Volume Down + + - Toggle Mute - + + Toggle Mute + + - Toggle De-Emphasis - - + + Toggle De-Emphasis + + + diff --git a/RedBookPlayer.GUI/themes/Default/view.xaml b/RedBookPlayer.GUI/themes/Default/view.xaml index 83d1b6f..54bfa19 100644 --- a/RedBookPlayer.GUI/themes/Default/view.xaml +++ b/RedBookPlayer.GUI/themes/Default/view.xaml @@ -103,7 +103,8 @@ 4CH HIDDEN HIDDEN - + + \ No newline at end of file diff --git a/RedBookPlayer.Models/Discs/CompactDisc.cs b/RedBookPlayer.Models/Discs/CompactDisc.cs index 9759b6f..3cf7e8d 100644 --- a/RedBookPlayer.Models/Discs/CompactDisc.cs +++ b/RedBookPlayer.Models/Discs/CompactDisc.cs @@ -299,13 +299,14 @@ namespace RedBookPlayer.Models.Discs } /// - public override void Init(IOpticalMediaImage image, bool autoPlay) + public override void Init(string path, IOpticalMediaImage image, bool autoPlay) { // If the image is null, we can't do anything if(image == null) return; // Set the current disc image + ImagePath = path; _image = image; // Attempt to load the TOC diff --git a/RedBookPlayer.Models/Discs/OpticalDiscBase.cs b/RedBookPlayer.Models/Discs/OpticalDiscBase.cs index 0a31b9b..c871713 100644 --- a/RedBookPlayer.Models/Discs/OpticalDiscBase.cs +++ b/RedBookPlayer.Models/Discs/OpticalDiscBase.cs @@ -8,6 +8,11 @@ namespace RedBookPlayer.Models.Discs { #region Public Fields + /// + /// Path to the disc image + /// + public string ImagePath { get; protected set; } + /// /// Indicate if the disc is ready to be used /// @@ -93,9 +98,10 @@ namespace RedBookPlayer.Models.Discs /// /// Initialize the disc with a given image /// + /// Path of the image /// Aaruformat image to load /// True if playback should begin immediately, false otherwise - public abstract void Init(IOpticalMediaImage image, bool autoPlay); + public abstract void Init(string path, IOpticalMediaImage image, bool autoPlay); #region Seeking diff --git a/RedBookPlayer.Models/Factories/OpticalDiscFactory.cs b/RedBookPlayer.Models/Factories/OpticalDiscFactory.cs index 5023a6b..fc0e0f0 100644 --- a/RedBookPlayer.Models/Factories/OpticalDiscFactory.cs +++ b/RedBookPlayer.Models/Factories/OpticalDiscFactory.cs @@ -32,7 +32,7 @@ namespace RedBookPlayer.Models.Factories image.Open(filter); // Generate and instantiate the disc - return GenerateFromImage(image, options, autoPlay); + return GenerateFromImage(path, image, options, autoPlay); } catch { @@ -44,11 +44,12 @@ namespace RedBookPlayer.Models.Factories /// /// Generate an OpticalDisc from an input IOpticalMediaImage /// + /// Path of the image /// IOpticalMediaImage to create from /// Options to pass to the optical disc factory /// True if the image should be playable immediately, false otherwise /// Instantiated OpticalDisc, if possible - public static OpticalDiscBase GenerateFromImage(IOpticalMediaImage image, OpticalDiscOptions options, bool autoPlay) + public static OpticalDiscBase GenerateFromImage(string path, IOpticalMediaImage image, OpticalDiscOptions options, bool autoPlay) { // If the image is not usable, we don't do anything if(!IsUsableImage(image)) @@ -74,7 +75,7 @@ namespace RedBookPlayer.Models.Factories return opticalDisc; // Instantiate the disc and return - opticalDisc.Init(image, autoPlay); + opticalDisc.Init(path, image, autoPlay); return opticalDisc; } diff --git a/RedBookPlayer.Models/Hardware/Player.cs b/RedBookPlayer.Models/Hardware/Player.cs index 4ab1883..0d04f33 100644 --- a/RedBookPlayer.Models/Hardware/Player.cs +++ b/RedBookPlayer.Models/Hardware/Player.cs @@ -41,6 +41,15 @@ namespace RedBookPlayer.Models.Hardware #region OpticalDisc Passthrough + /// + /// Path to the disc image + /// + public string ImagePath + { + get => _imagePath; + private set => this.RaiseAndSetIfChanged(ref _imagePath, value); + } + /// /// Current track number /// @@ -156,6 +165,7 @@ namespace RedBookPlayer.Models.Hardware /// public ulong TotalTime => _opticalDiscs[CurrentDisc]?.TotalTime ?? 0; + private string _imagePath; private int _currentTrackNumber; private ushort _currentTrackIndex; private ushort _currentTrackSession; @@ -669,6 +679,7 @@ namespace RedBookPlayer.Models.Hardware /// private void OpticalDiscStateChanged(object sender, PropertyChangedEventArgs e) { + ImagePath = _opticalDiscs[CurrentDisc].ImagePath; CurrentTrackNumber = _opticalDiscs[CurrentDisc].CurrentTrackNumber; CurrentTrackIndex = _opticalDiscs[CurrentDisc].CurrentTrackIndex; CurrentSector = _opticalDiscs[CurrentDisc].CurrentSector;