Hi
I want Read and play a sound file in c# as byte by byte. this bytes that reading, place in array of byte by lengh 500000. Now i want play this array! Please help me.
System.IO.FileStream fs = new System.IO.FileStream(@"c:\a.wav", System.IO.FileMode.Open);
byte[] buffer = new byte[500000];
byte[] buffer = new byte[500000];
fs.Read(buffer, 0, buffer.Length);
system.IO.Stream s = new system.IO.MemoryStream(buffer);
System.Media.SoundPlayer spPlayer = new System.Media.SoundPlayer(s);
spPlayer.Stream = s;
spPlayer.Stream.Position = 0;
spPlayer.Play();
Please Help what is Problem of my code?
Loading
yaquza yaquzaPosted Jan 25, 2012, 5:04 AM
FroglegPosted Jan 25, 2012, 3:30 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
namespace SimpleSound
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SoundPlayer mySound = new SoundPlayer(@"C:\a.wav");
mySound.Play();
}
}
}