Tutorial #2

Playing background Music

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 witch could do this. I try lot off 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 !

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 !

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 )

h% = WinExec(path$ + "/mpxplay/mpxplay.exe " + path$ + "/mod/music.ogg", SW_HIDE)


h% = WinExec(path$ + "/mpxplay/kill.bat",SW_HIDE)

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:


Then save it as KILL.BAT

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

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