播放文件RM音频c#

问题描述 投票:0回答:1

如何在 C# 中播放 RA 音频文件

RA 音频文件

使WindowsMediaPlayer支持ra文件或在另一个文件中播放单个文件 文件无法在 WindowsMediaPlayer 中播放 代码 C# 在 WindowsMediaPlayer 中播放 如何在 C# 中播放 RA 音频文件?

c# visual-studio-2010
1个回答
0
投票

使用 NAudio 为 RA 文件创建音频文件阅读器 这是一个例子:

using NAudio.Wave;

class Program 
{
  static void Main(string[] args)
  {
    // create an audio file reader for the RA file
    WaveStream pcmReader = new RawSourceWaveStream(new FileStream("audio.ra", FileMode.Open), 
       new WaveFormat(44100, 16, 2));

    // create an output device to play the audio
    WaveOutEvent outputDevice = new WaveOutEvent();

    // start playback
    outputDevice.Init(pcmReader);
    outputDevice.Play();

    // keep running until playback finishes
    while (outputDevice.PlaybackState == PlaybackState.Playing)
    {
      System.Threading.Thread.Sleep(100);
    }
    
    outputDevice.Dispose();
    pcmReader.Dispose();
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.