📄 dmusic.bas
字号:
Attribute VB_Name = "DMusic"
Option Explicit
Dim mobjPerf As DirectMusicPerformance
Dim mobjSeg As DirectMusicSegment
Dim mobjLoader As DirectMusicLoader
Public Sub Initialize()
Dim x As Integer
Dim udtPortCaps As DMUS_PORTCAPS
'Initialize
Set gdx = New DirectX7
Set mobjLoader = gdx.DirectMusicLoaderCreate()
Set mobjPerf = gdx.DirectMusicPerformanceCreate()
mobjPerf.Init Nothing, 0
'Get the port
For x = 1 To mobjPerf.GetPortCount
Call mobjPerf.GetPortCaps(x, udtPortCaps)
If udtPortCaps.lFlags And DMUS_PC_SHAREABLE Then
mobjPerf.SetPort x, 1
Exit For
End If
Next x
End Sub
Public Sub Play(strSong As String)
'Load and play the file
gstrMusicPlaying = strSong
Set mobjSeg = mobjLoader.LoadSegment(App.Path & "\" & strSong)
mobjSeg.SetLoopPoints 0, mobjSeg.GetLength - 3000
mobjSeg.SetRepeats 99
mobjPerf.PlaySegment mobjSeg, 0, 0
End Sub
Public Sub Terminate()
Set mobjSeg = Nothing
mobjPerf.CloseDown
Set mobjPerf = Nothing
Set mobjLoader = Nothing
Set gdx = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -