Delphi: play sound from memorystream.

var Form1: TForm1; ms: TMemoryStream; : procedure PlayWaveStream(Stream: TMemoryStream); begin if Stream = nil then sndPlaySound(nil, SND_ASYNC) //stop sound else sndPlaySound(Stream.Memory, (SND_ASYNC or SND_MEMORY)); end; procedure TForm1.Button1Click(Sender: TObject); begin ms.LoadFromFile('c:\Eddie\winner.wav'); ms.Position := 0; PlayWaveStream(ms); end; procedure TForm1.FormCreate(Sender: TObject); begin ms := TMemoryStream.Create; end; procedure TForm1.FormDestroy(Sender: TObject); begin ms.Free; end;

1 Response

Delphi is an Assassin! Nice!

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.