Restored from previous forum. Originally posted by MrVainSCL.
Hi Blue-Speed (BlueScreen

)
I played a bit around with your code and now i founded a way to play MidiTunes in your program/game... Just have a look to my example... Its not the best way but it seems to work... Please document your source in english, its easier to understand for other people if you post something in this list i think...

)
Falls Du probleme mit dem source hast, dann melde dich einfach. Good Luck...
;-----------------------------------
;
; PB Example to PlayMidi in Games
; by Mr.Vain of Secretly!
;
; (12-Dec-2001 - 23:24 pm)
;
;-----------------------------------
Global texty : texty = 600
;
;-------- Init and Play MidiTune --------
;
; Note: If you are planing to play a MidiTune in your game (using screen), you have to InitMovie() first!
; If you try to InitSprite() first, its not possible to play our Midi...!? So we will Init all the other
; stuff later... Does someone in this forum know how to use and play midi using 100% WinAPI commands?

; Please mail me, thanks!
;
If InitMovie() = 0
MessageBox_ (0,"Can't open DirectX 7 or later", "Error", #MB_ICONINFORMATION|#MB_OK)
EndIf
;-------- Load and Play Midi --------
;
; Its not possible to play Midi on a screen, because the PlayMovie() command need a event to play stuff,
; so we will trick a bit and open a small hidden window to play our background MidiTune! Its not the best
; way but it still works - i hope...
;
If LoadMovie(0, "Tune.mid") ;MovieName$)
OpenWindow(0, 0, 0, 1, 1, #PB_Window_SystemMenu, "PlayMidi Example for Games")
PlayMovie(0, WindowID()) ; Why isnt it possible to use "PlayMovie(0,ScreenID())" ?

)
Else
MessageBox_ (0,"Can't load MidiTune", "Error", #MB_ICONINFORMATION|#MB_OK)
EndIf
;-------- Info --------
;
; If nothing failed, we should hear the background tune...
; Now we can Init all the other stuff and open our screen...
;
;
;-------- Init all the needed system stuff --------
;
If InitSprite() = 0 Or InitKeyboard() = 0
MessageBox_ (0,"Can't open DirectX 7 or later", "Error", #MB_ICONINFORMATION|#MB_OK)
End
EndIf
;
;-------- Init Screen and load stuff --------
;
If OpenScreen(800,600,32,"PB Example To PlayMidi in Game") = 0 ; INITSPRITE; INITPAL
MessageBox_ (0,"Could not open 640x480x16 screen", "Error", #MB_ICONINFORMATION|#MB_OK) ; MUST SET BEFORE
End ; ELSE CRASH! ;(
EndIf
LoadSprite ( 0, "Background.bmp",0) ; For example 800x600 Picture to fill the Background
LoadSprite ( 1, "SmallLogo.bmp",0) ; For example any small Picture for scrolling in Forground...
;-----------------------------------------
; M a i n L o o p -> Scroll Graphic
;-----------------------------------------
Repeat
ClearScreen(0,0,0)
If texty >= -700
texty = texty - 1
EndIf
If texty <= -700
texty = 600
EndIf
DisplaySprite ( 0, 0, 0)
DisplaySprite ( 1, 0, texty)
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End ; This will end our program and will automatical close our hidden window and stop the background Midi
;----------------------------------------------------------------------
MrVainSCL!