Ejemplo: cómo escribir un archivo de audio desde una matriz de bytes C #
// to access the audio files themselves in your computer,
// you need to access the 'Name' property from the FileStream(s)
using Microsoft.VisualBasic.Devices;
using System.IO;
public class AudioFileWAV
{
public static FileStream Create(byte[] audio, string outputName)
{
using (FileStream bytesToAudio = File.Create(outputName + ".wav"))
{
bytesToAudio.Write(audio, 0, audio.Length);
Stream audioFile = bytesToAudio;
bytesToAudio.Close();
return audioFile;
}
}
public static void Play(string audioFile)
{
new Audio().Play(audioFile);
}
}
public class AudioFileMP3
{
public static FileStream Create(byte[] audio, string outputName)
{
using (FileStream bytesToAudio = File.Create(outputName + ".mp3"))
{
bytesToAudio.Write(audio, 0, audio.Length);
Stream audioFile = bytesToAudio;
bytesToAudio.Close();
return audioFile;
}
}
}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)