Since a long time I try to find how to play music (*.mod or *.ogg files) using GFA Basic 16. Unfortunately I never found DLL which could do this. I try lot of possibilities without success.

A few years ago I found Mpxplay and it give me some hope because using WinExec I have succeeded in playing OGG music files !

Le problème initial

But there was a big problem: I could not stop the music !

There was no code or command line instruction that can stop the music with Mpxplay !

I stumbled a few days ago by doing a search on google on a message from a user who asks how to kill a process in Visual Basic ...

Then I wondered if there was a Windows function that allow to stop a process, therefore to stop the player !

La solution

Here is the code (I try it on "Windows 7 x86" and on "Windows 7 x64" using "Microsoft Virtual PC 2007"):

' --- Play OGG files in GFA Windows 16 ' ' --------------------------- ' DLL for calling Windows exe ' --------------------------- ' If someone know how to kill task using Kernel win 16, please explain me ! thanks ! ' DLL #1, "kernel" DECL WORD WinExec( l, w ) ENDDLL h% = WinExec(path$ + "/mpxplay/mpxplay.exe " + path$ + "/mod/music.ogg", SW_HIDE) REPEAT UNTIL MOUSEK=2 h% = WinExec(path$ + "/mpxplay/kill.bat",SW_HIDE) FREEDLL 1

Le fichier kill.bat

Oups, I don't speak about "kill.bat", it's just a small *.BAT file you can create with NOTEPAD. This file contain the following code:

TASKKILL /IM MPXPLAY.EXE

Then save it as KILL.BAT

Note : Of course it's not a nice way to code, but it works !!!

Conversion des fichiers MOD

PS: I use MOD to OGG converter online to convert MOD musics in OGG.

Explication : Cette méthode utilise un player externe (Mpxplay) lancé via WinExec et un fichier batch pour arrêter la lecture. Bien que peu élégante, cette solution fonctionne avec GFA Basic 16.