I will play an mp3 directly from a zip file.
I have zipmaster for delphi which supports
so i will give this created stream to fmod to play it, but the openfile function doesnt work :/ .. i would need something like playfromstream or so…
is there any way to do that!?
any help would be very great,
- spitron asked 17 years ago
Here is a tested and working implementation of file callbacks in Delphi to use streams.
<pre>function OpenCallback(Name: PChar): Cardinal; cdecl;
// Open a filestream to the given filename
Stream := TFileStream.Create(String(Name), fmOpenRead or fmShareDenyNone);
// Return the pointer to the filestream as the file handle
Result := Cardinal(Stream);
procedure CloseCallback(Handle: Cardinal); cdecl;
// The handle is the pointer to the filestream
function ReadCallback(Buffer: Pointer; Size: Cardinal; Handle: Cardinal): Cardinal; cdecl;
// Read Size bytes into Buffer and return the actual number of bytes read
Result := TFileStream(Handle).Read(Buffer^, Size);
procedure SeekCallback(Handle: Cardinal; Pos: Cardinal; Mode: Byte); cdecl;
// Seek to the given position in the stream
// Mode 0 = soFromBeginning, 1 = soFromCurrent, 2 = soFromEnd
function TellCallback(Handle: Cardinal): Cardinal; cdecl;
// Return the current position in the stream
Result := TFileStream(Handle).Position;
procedure TfrmMain.FormCreate(Sender: TObject);
FSOUND_File_SetCallbacks(OpenCallback, CloseCallback, Readcallback, SeekCallback, TellCallback);
FSOUND_Init(22050, 128, 0);
end;</pre>In the process of testing this, I found a small bug in my translation of the FMOD headers. The Seek callback has a Byte parameter that is incorrectly specified as ByteBool. This is on line 56 of fmod.pas.
Please login first to submit.