StopMusic will stop a previously playing music channel. To play this channel again, use'll have to use PlayMusic command.
FACTS:
* Use PlayMusic to start stopped music
* You can find this Example in the PlayBasic\Projects\Music folder
Mini Tutorial:
This example will load a music file then let the user control the musics playback with various keyboard controls.
; Ask PB for a free Music Index MusicIndex=GetFreeMusic() Do Cls RGB(0,0,0) ; Display Instructions Print "Music Example" Print "" Print " F1 = Load Music" Print " F2 = Play Music" Print " F3 = Pause Music" Print " F4 = Resume Music" Print " F5 = Stop Music" Print " Up/Down Arrows = Volume Control" Print " Left/Right Arrows = Pan Control" Print "" ; Load the load track (init streaming of this track) If FunctionKeys(1) Then LoadMusic "..\..\..\Music\Ambient.xm",MusicIndex ; Get the Status of the music If GetMusicStatus(Musicindex)=true ; If the F2 key is pressed play the music If FunctionKeys(2) Then PlayMusic MusicIndex ; If the F3 key is pressed Pause the music If FunctionKeys(3) Then PauseMusic MusicIndex ; If the F4 key is pressed Resume the music If FunctionKeys(4) Then ResumeMusic MusicIndex ; If the F5 key is pressed Stop the music If FunctionKeys(5) Then StopMusic MusicIndex Volume=GetMusicVolume(MusicIndex) ; If the Up arrow is pressed increase the volume If UpKey() Then MusicVolume MusicIndex,Volume+1 ; If the Down arrow is pressed decrease the volume If DownKey() Then MusicVolume MusicIndex,Volume-1 ; Get the Pan of the music Pan=GetMusicPan(MusicIndex) ; if the Left arrow is press pan the music left If LeftKey() Then MusicPan MusicIndex,Pan-1 ; if the Right arrow is press pan the music Right If RightKey() Then MusicPan MusicIndex,Pan+1 Else Volume=0 pan=0 EndIf ;Display the Music Status Print "" Print " Music Current Status:"+Str$(GetMusicStatus(1)) Print " Music Current Volume:"+Str$(Volume) Print " Music Current Pan:"+Str$(Pan) Print "" ; Show the Music playing Status Select GetMusicPlaying(MusicIndex) Case -1 mode$="Music is Not LOADED" Case 0 mode$= "Music Is Loaded but Not Playing" Case 1 Mode$= "Music Is Playing" Case 2 Mode$="Music Paused" Case 3 Mode$="Music Playing + Paused" EndSelect Print "Current Music Status:"+mode$ ; Delete all music tracks if the space key is pressed If SpaceKey() DeleteAllMusics EndIf ; refresh the screen Sync ; loop back to the DO statement Loop |
|