123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- // See https://aka.ms/new-console-template for more information
- using System;
- using System.Threading;
- using Bmp.Core.Common.Net;
- using Bmp.Core.NAudioExt;
- using Bmp.Core.Playback.Inputs;
- using NAudio.Wave;
- using AsioOut = Bmp.Core.Playback.Outputs.NAudioASIO.AsioOut;
- using static Bmp.Poc.Const;
- namespace Bmp.Poc.PoCs;
- internal class PocAsioFFMpegHttpSeekingPlayback
- {
- public static void MainFunc()
- {
- var asioDriverName = "Creative SB USB RT ASIO Device";
- var shs = new SeekableHttpStream(UrlFlac24Bit96Khz);
- var source = new FFMPEGAudioReader(shs);
- //var source = new NAudioFFMPEGAudioReader(UrlFlac24Bit96Khz);
- var sourceBitPerRawSample = source.BitPerRawSample;
- var vdWrap = new VisualizeDataMiddleWrap(source);
- var vdSourceBitPerRawSample = source.BitPerRawSample;
- var driverNames = AsioOut.GetDriverNames();
- var driverIndex = Array.IndexOf(driverNames, asioDriverName);
- var outputDevice = new AsioOut(driverIndex);
- vdWrap.DataTransferred += (_, args) =>
- {
- Console.WriteLine($"{DateTime.Now:HH:mm:ss.ff} {nameof(vdWrap.DataTransferred)}:{args.Bytes.Length}");
- };
- outputDevice.Init(vdWrap);
- outputDevice.Play();
- while (outputDevice.PlaybackState == PlaybackState.Playing)
- {
- Console.WriteLine($"{source.CurrentTime}/{source.TotalTime}");
- Thread.Sleep(3000);
- outputDevice.Pause();
- source.CurrentTime = source.CurrentTime.Add(TimeSpan.FromSeconds(1));
- Thread.Sleep(100);
- outputDevice.Play();
- }
- }
- }
|