mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Implement IAudioSource.Duration property and IAudioDecoderSettings.Open extension method.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
|
||||
namespace CUETools.Codecs
|
||||
{
|
||||
@@ -44,5 +45,10 @@ namespace CUETools.Codecs
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
property.ResetValue(settings);
|
||||
}
|
||||
|
||||
public static IAudioSource Open(this IAudioDecoderSettings settings, string path, Stream IO = null)
|
||||
{
|
||||
return Activator.CreateInstance(settings.DecoderType, settings, path, IO) as IAudioSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace CUETools.Codecs
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Duration => Length < 0 ? TimeSpan.Zero : TimeSpan.FromSeconds((double)Length / PCM.SampleRate);
|
||||
|
||||
public long Length
|
||||
{
|
||||
get
|
||||
|
||||
@@ -27,6 +27,15 @@ namespace CUETools.Codecs.CommandLine
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Duration
|
||||
{
|
||||
get
|
||||
{
|
||||
Initialize();
|
||||
return rdr.Duration;
|
||||
}
|
||||
}
|
||||
|
||||
public long Length
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CUETools.Codecs
|
||||
using System;
|
||||
|
||||
namespace CUETools.Codecs
|
||||
{
|
||||
public interface IAudioSource
|
||||
{
|
||||
@@ -7,7 +9,8 @@
|
||||
AudioPCMConfig PCM { get; }
|
||||
string Path { get; }
|
||||
|
||||
long Length { get; }
|
||||
TimeSpan Duration { get; }
|
||||
long Length { get; }
|
||||
long Position { get; set; }
|
||||
long Remaining { get; }
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CUETools.Codecs.NULL
|
||||
using System;
|
||||
|
||||
namespace CUETools.Codecs.NULL
|
||||
{
|
||||
public class AudioDecoder : IAudioSource
|
||||
{
|
||||
@@ -8,6 +10,8 @@
|
||||
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public TimeSpan Duration => TimeSpan.FromSeconds((double)Length / PCM.SampleRate);
|
||||
|
||||
public long Length
|
||||
{
|
||||
get { return _sampleCount; }
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace CUETools.Codecs.WAV
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Duration => Length < 0 ? TimeSpan.Zero : TimeSpan.FromSeconds((double)Length / PCM.SampleRate);
|
||||
|
||||
public long Length
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user