Dark Basic Pro Programming #02 (By Fable Fox)
Music & Embedded Music
You might say that I jumped from Hello World to playing music file and embedding it into the .exe too quick. Yep, you are right. But I'm doing the 'shock advertising' thing. If people know how easy it is to use DBP, only then they are willing to stick around and learn other core things like loop and logic.
Now type these two lines of very short code, between the original two short code. But before you run it, just copy a midi and rename it to canon.mid into a directory called data. In the same directory you save the project and the source code to. Maybe when we go into even more complex programs for future HUGI, I'll add the source code and project files too. But for now, the code is short so just copy it.
print "HUGI rulez!" load music "data\canon.mid",1 play music 1 wait key
Now compile and run the program by pressing F5. Wow, now your program plays a MIDI file. But, how do we include it in the .exe? Well, from the Project Explorer, right click and select Add Media.
There is another thing that you must set up. At the project manager, select Executable with Media for the Build Type. Please note that now I also add Application Title so the window title has a proper title now.
Now press F5. The program will compile and run nicely. To test its embedding, just copy only the exe to different directory, or even drive. The program will run just fine as the MIDI file is now included in the .exe.
This embedding works for other DBP media files. See you in the next tutorial.