I tried to add mp3 audio playback (LAME encoded) to my Inno setup program using Inno Media Player and following @TLama's decription -> https://stackoverflow.com/a/12360780/3838926. I use Windows 7 64bit with Unicode Inno.
Unfortunately it fails: When opening the installer I get the following error message: TDirectShowPlayer error: -2147220890;
Searching through Google didn't help.
What do I do wrong? Is it a bug in the program? I'm clueless...
Here's the exact code:
const
EC_COMPLETE = $01;
type
TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);
function DSGetLastError(var ErrorText: WideString): HRESULT;
external 'DSGetLastError@files:mediaplayer.dll stdcall';
function DSPlayMediaFile: Boolean;
external 'DSPlayMediaFile@files:mediaplayer.dll stdcall';
function DSStopMediaPlay: Boolean;
external 'DSStopMediaPlay@files:mediaplayer.dll stdcall';
function DSSetVolume(Value: LongInt): Boolean;
external 'DSSetVolume@files:mediaplayer.dll stdcall';
function DSInitializeAudioFile(FileName: WideString;
CallbackProc: TDirectShowEventProc): Boolean;
external 'DSInitializeAudioFile@files:mediaplayer.dll stdcall';
procedure OnMediaPlayerEvent(EventCode, Param1, Param2: Integer);
begin
if EventCode = EC_COMPLETE then
begin
// playback is done, so you can e.g. play the stream again, play another
// one using the same code as in InitializeWizard (in that case would be
// better to wrap that in some helper function) or do just nothing
end;
end;
procedure InitializeWizard;
var
ErrorCode: HRESULT;
ErrorText: WideString;
begin
ExtractTemporaryFile('InDeep.mp3');
if DSInitializeAudioFile(ExpandConstant('{tmp}\InDeep.mp3'),
@OnMediaPlayerEvent) then
begin
DSSetVolume(-2500);
DSPlayMediaFile;
end
else
begin
ErrorCode := DSGetLastError(ErrorText);
MsgBox('TDirectShowPlayer error: ' + IntToStr(ErrorCode) + '; ' +
ErrorText, mbError, MB_OK);
end;
end;
procedure DeinitializeSetup;
begin
DSStopMediaPlay;
end;
InDeep.mp3 is my audio file.
Thanks in advance!!