/// <summary> /// 设置值并且播放 /// </summary> /// <param name="val"></param> /// <param name="play"></param> public void SetValue(double val, bool play = false) { if (val >= 0 && val <= AudioLength && waveOut != null && wavStream != null) { wavStream?.SetPosition(TimeSpan.FromSeconds(val)); if (play) { //if (waveOut.PlaybackState != PlaybackState.Playing) //{ waveOut.Play(); //} } else { waveOut.Stop(); } } }
// Set playback position of WaveStream relative to current position public static void Seek(this WaveStream strm, double offset) { strm.SetPosition(strm.Position + (long)(offset * strm.WaveFormat.AverageBytesPerSecond)); }
// Set playback position of WaveStream by time (as a TimeSpan) public static void SetPosition(this WaveStream strm, TimeSpan time) { strm.SetPosition(time.TotalSeconds); }
// Set playback position of WaveStream by seconds public static void SetPosition(this WaveStream strm, double seconds) { strm.SetPosition((long)(seconds * strm.WaveFormat.AverageBytesPerSecond)); }
public void SongJump(TimeSpan time) { _blockAlignedStream.SetPosition(time); }
public static void Seek(this WaveStream _stream, double _offset) { _stream.SetPosition(_stream.Position + (long)(_offset * _stream.WaveFormat.AverageBytesPerSecond)); }
public static void SetPosition(this WaveStream _stream, TimeSpan _time) { _stream.SetPosition(_time.TotalSeconds); }
public static void SetPosition(this WaveStream _stream, double _seconds) { _stream.SetPosition((long)_seconds * _stream.WaveFormat.AverageBytesPerSecond); }