mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Wire up disc changing to UI
This commit is contained in:
@@ -299,13 +299,14 @@ namespace RedBookPlayer.Models.Discs
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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
|
||||
|
||||
@@ -8,6 +8,11 @@ namespace RedBookPlayer.Models.Discs
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Path to the disc image
|
||||
/// </summary>
|
||||
public string ImagePath { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicate if the disc is ready to be used
|
||||
/// </summary>
|
||||
@@ -93,9 +98,10 @@ namespace RedBookPlayer.Models.Discs
|
||||
/// <summary>
|
||||
/// Initialize the disc with a given image
|
||||
/// </summary>
|
||||
/// <param name="path">Path of the image</param>
|
||||
/// <param name="image">Aaruformat image to load</param>
|
||||
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
||||
public abstract void Init(IOpticalMediaImage image, bool autoPlay);
|
||||
public abstract void Init(string path, IOpticalMediaImage image, bool autoPlay);
|
||||
|
||||
#region Seeking
|
||||
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Generate an OpticalDisc from an input IOpticalMediaImage
|
||||
/// </summary>
|
||||
/// <param name="path">Path of the image</param>
|
||||
/// <param name="image">IOpticalMediaImage to create from</param>
|
||||
/// <param name="options">Options to pass to the optical disc factory</param>
|
||||
/// <param name="autoPlay">True if the image should be playable immediately, false otherwise</param>
|
||||
/// <returns>Instantiated OpticalDisc, if possible</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,15 @@ namespace RedBookPlayer.Models.Hardware
|
||||
|
||||
#region OpticalDisc Passthrough
|
||||
|
||||
/// <summary>
|
||||
/// Path to the disc image
|
||||
/// </summary>
|
||||
public string ImagePath
|
||||
{
|
||||
get => _imagePath;
|
||||
private set => this.RaiseAndSetIfChanged(ref _imagePath, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current track number
|
||||
/// </summary>
|
||||
@@ -156,6 +165,7 @@ namespace RedBookPlayer.Models.Hardware
|
||||
/// </summary>
|
||||
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
|
||||
/// </summary>
|
||||
private void OpticalDiscStateChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
ImagePath = _opticalDiscs[CurrentDisc].ImagePath;
|
||||
CurrentTrackNumber = _opticalDiscs[CurrentDisc].CurrentTrackNumber;
|
||||
CurrentTrackIndex = _opticalDiscs[CurrentDisc].CurrentTrackIndex;
|
||||
CurrentSector = _opticalDiscs[CurrentDisc].CurrentSector;
|
||||
|
||||
Reference in New Issue
Block a user