0
0

Hello,

I am design at moment a player basing on FMOD, but now I have a problem. If my Player is finish with the first file and he start to playing the second file he do not release the first file.
Play-Source:
[code:1zazkxwf]function TPlayer.Play(PlayIndex: Integer): Boolean;
var
Return: FMOD_RESULT;
Paused: LongBool;
PlayPos: Cardinal;
begin
Result:=false;
PlayList.PlayIndex:=PlayIndex;
if FChannel1<>nil then FMOD_Channel_GetPaused(FChannel1, Paused)
else Paused:=false;
if not Paused then
begin
iStop;
PlayList.PlayIndex:=PlayIndex;
if (PlayList.PlayIndex>-1) and (PlayList.PlayIndex<PlayList.PlayListCount) then
begin
FMOD_System_CreateSound(FSystem,
PAnsiChar(PlayList.PlayListItems[PlayList.PlayIndex].FileFolder+PlayList.PlayListItems[PlayList.PlayIndex].FileName),
FMOD_Software or FMOD_3D or FMOD_CREATESTREAM or FMOD_UNICODE,
nil,
FSound1);
Return:=FMOD_System_PlaySound(FSystem, FMOD_CHANNEL_FREE, FSound1, false, FChannel1);
if Return<>FMOD_OK then
begin
PlayerGUI.Stop;
Application.MessageBox(PAnsiChar(’FMOD error! – ‘ + FMOD_ErrorString(Return)), ‘FMOD – Error’, 16);
end
else
begin
if FMOD_Sound_GetLength(FSound1, FDuration1, FMOD_TIMEUNIT_MS)=FMOD_OK then
begin
Result:=true;
PlayerGUI.Play;
FNextTitleTimer:=timeSetEvent(FDuration1, 1, @NextTitle, 0, TIME_ONESHOT);
FSetScrollPosTimer:=timeSetEvent(FDuration1 div FScrollSize, 1, @SetScrollPosition, 0, TIME_PERIODIC);
end
end
end
end
else
begin
if FMOD_Channel_SetPaused(FChannel1, false)=FMOD_OK then
begin
FMOD_Channel_GetPosition(FChannel1, PlayPos, FMOD_TIMEUNIT_MS);
FNextTitleTimer:=timeSetEvent(FDuration1-PlayPos, 1, @NextTitle, 0, TIME_ONESHOT);
FSetScrollPosTimer:=timeSetEvent(FDuration1 div FScrollSize, 1, @SetScrollPosition, 0, TIME_PERIODIC);
Result:=true;
PlayerGUI.Play;
end
end
end;[/code:1zazkxwf]

and the stop function:

[code:1zazkxwf]procedure TPlayer.iStop;
begin
//Timer stoppen
timeKillEvent(FNextTitleTimer);
timeKillEvent(FSetScrollPosTimer);

//Channels stoppen
FMOD_Channel_Stop(FChannel1);
// FMOD_Channel_Stop(FChannel2);

if FSound1<> nil then FMOD_System_Release(FSound1);
end;[/code:1zazkxwf]

Where is my misstake?

  • You must to post comments
0
0

Why did you call FMOD_System_Release with a sound parameter? The header specifically says that it requires FMOD_SYSTEM not FMOD_SOUND.
To release a sound you use FMOD_Sound_Release.

  • You must to post comments
0
0

Oh yes, that was my tipping error ;).

thanks no I works correctly :).

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.