
Just wondering how to pause a music module that's been started with PlayModule(Music)
There is a PauseSound() command but i tried that and it crashed!
I am using mod's for music to keep it Amiga'ish
Thanks
Code: Select all
If KeyboardPushed(#PB_Key_Escape)
ReleaseMouse(#True)
PauseSound(#PB_All)
ModulePos = GetModulePosition(Music)
If ModulePos > 0
StopModule(Music)
EndIf
If MessageRequester(#Title,"Quit, Are You Sure",#Flags) = 6
Quit = #True
Else
If ModulePos > 0
SetModulePosition(Music,ModulePos)
PlayModule(Music)
EndIf
ReleaseMouse(#False)
ResumeSound(#PB_All)
EndIf
EndIf
Hello Pot Noodle. From the following example, it seems that the StopMusic() function actually pauses the music, and any subsequent PlayMusic() call to the corresponding MOD or XM file simply resumes playback from where it was stopped:Pot Noodle wrote:Just wondering how to pause a music module that's been started with PlayModule(Music)
Code: Select all
InitNetwork()
InitSound()
Enumeration
#MainWindow
#Player1
#Player2
#modMusic
#xmMusic
EndEnumeration
ReceiveHTTPFile("https://www.dropbox.com/s/zqw2pjyytyjq2q5/arabia.mod?dl=1",
GetTemporaryDirectory() + "arabia.mod")
LoadMusic(#modMusic, GetTemporaryDirectory() + "arabia.mod")
MusicVolume(#modMusic, 60)
ReceiveHTTPFile("https://www.dropbox.com/s/mw1hbw9f1orxkg9/astro.xm?dl=1",
GetTemporaryDirectory() + "astro.xm")
LoadMusic(#xmMusic, GetTemporaryDirectory() + "astro.xm")
MusicVolume(#xmMusic, 60)
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 300, 100, "PlayMusic", wFlags)
ButtonGadget(#Player1, 30, 30, 100, 30, "Play MOD")
ButtonGadget(#Player2, 170, 30, 100, 30, "Play XM")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #Player1
If modFlag
SetGadgetText(#Player1, "Resume")
StopMusic(#modMusic)
modFlag = 0
Else
SetGadgetText(#Player1, "Pause")
PlayMusic(#modMusic)
modFlag = 1
EndIf
Case #Player2
If xmFlag
SetGadgetText(#Player2, "Resume")
StopMusic(#xmMusic)
xmFlag = 0
Else
SetGadgetText(#Player2, "Pause")
PlayMusic(#xmMusic)
xmFlag = 1
EndIf
EndSelect
EndSelect
Until appQuit = 1
EDITS wrote:18th February 2019: updated download links
Hi Pot Noodle. You're right; it is new with PureBasic v.5.20. In fact, the entire Module library has been renamed to facilitate the newly introduced module functions. Here's the update from Fred:Pot Noodle wrote:i get an error with LoadMusic(), is this a new command in ver 5.20 ?
Please give this a try; I've replaced the new music functions with their earlier module names, and removed the line continuations, to be more compatible with earlier versions of PureBasic:Fred wrote:Changed: renamed the whole 'Module' library to 'Music'
Code: Select all
;modified to work with PureBasic versions prior to 5.20
InitNetwork()
InitSound()
Enumeration
#MainWindow
#Player1
#Player2
#modMusic
#xmMusic
EndEnumeration
ReceiveHTTPFile("https://www.dropbox.com/s/zqw2pjyytyjq2q5/arabia.mod?dl=1", GetTemporaryDirectory() + "arabia.mod")
LoadModule(#modMusic, GetTemporaryDirectory() + "arabia.mod")
ReceiveHTTPFile("https://www.dropbox.com/s/mw1hbw9f1orxkg9/astro.xm?dl=1", GetTemporaryDirectory() + "astro.xm")
LoadModule(#xmMusic, GetTemporaryDirectory() + "astro.xm")
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 300, 100, "PlayMusic", wFlags)
ButtonGadget(#Player1, 30, 30, 100, 30, "Play MOD")
ButtonGadget(#Player2, 170, 30, 100, 30, "Play XM")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #Player1
If modFlag
SetGadgetText(#Player1, "Resume")
StopModule(#modMusic)
modFlag = 0
Else
SetGadgetText(#Player1, "Pause")
PlayModule(#modMusic)
modFlag = 1
EndIf
Case #Player2
If xmFlag
SetGadgetText(#Player2, "Resume")
StopModule(#xmMusic)
xmFlag = 0
Else
SetGadgetText(#Player2, "Pause")
PlayModule(#xmMusic)
xmFlag = 1
EndIf
EndSelect
EndSelect
Until appQuit = 1
EDITS wrote:18th February 2019: updated download links