gpt4 book ai didi

audio - 如何在vb6后台播放音乐?

转载 作者:行者123 更新时间:2023-12-03 02:04:50 30 4
gpt4 key购买 nike

嗨,我用vb6做一个小游戏,我需要在一段时间内播放2个声音
我用这个代码

 Private Declare Function PlaySoundMem Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As Long, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_ASYNC = &H1, SND_MEMORY = &H4, SND_NODEFAULT = &H2, SND_NOSTOP = &H1, SND_NOWAIT = &H2000
Dim Sound() As Byte
Dim x As Integer

Private Sub Form_Load()
On Error Resume Next
Sound = LoadResData("music", "CUSTOM")
Call PlaySoundMem(VarPtr(Sound(0)), 0, SND_NOWAIT Or SND_NODEFAULT Or SND_MEMORY Or SND_ASYNC Or SND_NOSTOP)
DoEvents

End Sub

Private Sub snd()
If nrd.Text = 1 Then
x = 1
snd_hero
ElseIf nrd.Text = 2 Then
x = 2
snd_hero
ElseIf nrd.Text = 3 Then
x = 3
snd_hero
ElseIf nrd.Text = 4 Then
x = 4
snd_hero
ElseIf nrd.Text = 5 Then
x = 5
snd_hero
ElseIf nrd.Text = 6 Then
x = 6
snd_hero
End If
End Sub

Private Sub snd_hero()
On Error Resume Next
Sound = LoadResData(x, "CUSTOM")
Call PlaySoundMem(VarPtr(Sound(0)), 0, SND_NOWAIT Or SND_NODEFAULT Or SND_MEMORY Or SND_ASYNC Or SND_NOSTOP)
DoEvents
ReDim Sound(0)

开始播放音乐,但停止播放其他声音
我需要演奏才能在某些时候发出声音,谢谢

最佳答案

您可以尝试使用Windows Media Player控件并将其设置为循环。由于它的行为类似于外部媒体播放器(在某种程度上),因此它将音频混入DirectShow中,因此不会阻止播放其他声音,反之亦然。

关于audio - 如何在vb6后台播放音乐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28397005/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com