This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
flxmusic.monkey
106 lines (79 loc) · 1.75 KB
/
flxmusic.monkey
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Strict
Import mojo.audio
Import flxsound
Import system.flxassetsmanager
Class FlxMusic Extends FlxSound
Global __CLASS__:Object
Private
Field _filename:String
Public
Method Kill:Void()
Super.Kill()
Stop()
End Method
Method Load:FlxSound(music:String, looped:Bool = False, autoDestroy:Bool = True, stopPrevious:Bool = True)
Stop()
_CreateSound()
_filename = FlxAssetsManager.GetMusicPath(music)
_looped = looped
_UpdateTransform()
exists = True
Return Self
End Method
Method Play:Void(forceRestart:Bool = False)
If (forceRestart) Then
Local oldAutoDestroy:Bool = autoDestroy
autoDestroy = False
Stop()
autoDestroy = oldAutoDestroy
End If
_UpdateTransform()
If (Not _paused) Then
PlayMusic(_filename, _looped)
Else
ResumeMusic()
End If
active = True
_paused = False
End Method
Method Resume:Void()
If (Not _paused) Return
ResumeMusic()
_paused = False
active = True
End Method
Method Pause:Void()
If (Not active) Return
PauseMusic()
_paused = True
active = False
End Method
Method Stop:Void()
_paused = False
active = False
StopMusic()
If (autoDestroy) Then
Destroy()
End If
End Method
Function GetValidExt:String()
#If FLX_MUSIC_EXTENSION = "wav"
Return "wav"
#ElseIf FLX_MUSIC_EXTENSION = "ogg"
Return "ogg"
#ElseIf FLX_MUSIC_EXTENSION = "mp3"
Return "mp3"
#ElseIf FLX_MUSIC_EXTENSION = "m4a"
Return "m4a"
#ElseIf FLX_MUSIC_EXTENSION = "caf"
Return "caf"
#ElseIf FLX_MUSIC_EXTENSION = "aiff"
Return "aiff"
#ElseIf FLX_MUSIC_EXTENSION = "unknown"
Return FlxGetValidSoundExt()
#End
End Function
Method _SetTransform:Void(volume:Float, pan:Float)
SetMusicVolume(volume)
End Method
End Class