-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSoundManagerNotifier.cls
119 lines (98 loc) · 3.17 KB
/
SoundManagerNotifier.cls
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
107
108
109
110
111
112
113
114
115
116
117
118
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "SoundManagerNotifier"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private Sub btnLoadAll_Click()
Dim i As Integer
On Error Resume Next
For i = btnLoad.LBound To btnLoad.UBound
If btnLoad(i).Enabled Then btnLoad_Click i
Next
End Sub
Private Sub btnPlayAll_Click()
Dim i As Integer
On Error Resume Next
For i = btnPlay.LBound To btnPlay.UBound
If btnPlay(i).Enabled Then btnPlay_Click i
Next
End Sub
Private Sub btnStopAll_Click()
SoundManager.StopSound ALL_SOUND_BUFFERS
End Sub
Private Sub btnFreeAll_Click()
SoundManager.FreeSound ALL_SOUND_BUFFERS
End Sub
Private Sub btnFree_Click(Index As Integer)
SoundManager.FreeSound Index
End Sub
Private Sub btnLoad_Click(Index As Integer)
SoundManager.LoadSoundFile Index, App.Path & "\Sounds\" & txtSoundFile(Index).Text
End Sub
Private Sub btnPlay_Click(Index As Integer)
SoundManager.PlaySound Index
End Sub
Private Sub btnStop_Click(Index As Integer)
SoundManager.StopSound Index
End Sub
Private Sub btnInstantSound_Click()
' Instantly load, play and free a sound using the first available buffer
' No notification is required
SoundManager.LoadSoundFile SoundManager.FreeBuffer, App.Path & "\Sounds\Oshppis3.wav", BufferFlagInstant
End Sub
Private Sub Form_Load()
Set SoundManager.Notifier = Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Very, Very Important. This MUST be called or a crash is inevitable
SoundManager.DestroySoundManager
End Sub
Private Sub SoundManagerNotifier_SoundLoaded(ByVal BufferIndex As Long)
With lblStatus(BufferIndex)
.Caption = "Loaded"
.ForeColor = vbBlue
End With
btnFree(BufferIndex).Enabled = True
btnLoad(BufferIndex).Enabled = True
btnPlay(BufferIndex).Enabled = True
btnStop(BufferIndex).Enabled = False
End Sub
Private Sub SoundManagerNotifier_SoundPlayEnd(ByVal BufferIndex As Long)
With lblStatus(BufferIndex)
.Caption = "Stopped"
.ForeColor = vbBlue
End With
btnFree(BufferIndex).Enabled = True
btnLoad(BufferIndex).Enabled = True
btnPlay(BufferIndex).Enabled = True
btnStop(BufferIndex).Enabled = False
End Sub
Private Sub SoundManagerNotifier_SoundPlayStart(ByVal BufferIndex As Long)
With lblStatus(BufferIndex)
.Caption = "Playing"
.ForeColor = vbGreen
End With
btnFree(BufferIndex).Enabled = True
btnLoad(BufferIndex).Enabled = True
btnPlay(BufferIndex).Enabled = False
btnStop(BufferIndex).Enabled = True
End Sub
Private Sub SoundManagerNotifier_SoundUnloaded(ByVal BufferIndex As Long)
With lblStatus(BufferIndex)
.Caption = "Empty"
.ForeColor = RGB(127, 127, 127)
End With
btnFree(BufferIndex).Enabled = False
btnLoad(BufferIndex).Enabled = True
btnPlay(BufferIndex).Enabled = False
btnStop(BufferIndex).Enabled = False
End Sub