All I need is a slight modification to what I already have ===Originally Posted by Sly
OK I'll get specific = here is some code that works well
taken from
http://delphi.about.com/od/objectpas.../aa021301c.htm
by Zarko Gajic
= thanks Zarko...
I have written to Zarko with no response = so this post...
================================
of course = first the .rc file and res file are created.... then =
{$R AboutDelphi.RES}
procedure TForm1.Button1Click(Sender: TObject);
var
rStream: TResourceStream;
fStream: TFileStream;
fname: string;
begin
{this part extracts the mp3 from exe}
fname:=ExtractFileDir(Paramstr(0))+'Intro.mp3';
rStream := TResourceStream.Create
(hInstance, 'Intro', RT_RCDATA);
try
fStream := TFileStream.Create(fname, fmCreate);
try
fStream.CopyFrom(rStream, 0);
finally
fStream.Free;
end;
finally
rStream.Free;
end;
{this part plays the mp3}
MediaPlayer1.Close;
MediaPlayer1.FileName:=fname;
MediaPlayer1.Open;
end;
now this uses the resource file that contains an mp3
and plays it with mediaplayer after creating the mp3 on your harddrive..
But can one play it directly from the resource without creating a file on the hd first ?
I actually think it's quite neat that ye olde mediaplayer will play mp3's if given a suitable filename....
I feel there must be an easy elegant solution but I don't know anything about streaming to mediaplayer from the exe...
I feel that the inherent simplicity of the above from Zarko just needs a polishing touch and it would be really useful to a lot of programmers that want to embed and play mp3's from the exe.
cheeeeeerrrrrrrrsssssss a
Bookmarks