gpt4 book ai didi

vb.net - 在特定时间播放声音-Winmm.dll-VB.Net

转载 作者:行者123 更新时间:2023-12-03 01:11:33 28 4
gpt4 key购买 nike

我开始使用winmm.dll播放声音(它提供了一次播放多种声音并设置音频参数的可能性),但我找不到该库所有功能的有效 list 。
我有一个包含更多音乐的Wav文件,因此我必须分别启动它们。
我有这个代码:

Imports System.Text
Imports System.Runtime.InteropServices

Public class SoundPlayer

<DllImport("winmm.dll")> Private Shared Function mciSendString(ByVal command As String, ByVal buffer As StringBuilder, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer
End Function

Public sub PlayMusicWithTime(SelectedTime as String)

mciSendString("open " & Chr(34) & Application.StartupPath & "\Resources\Sounds\" & soundFileName & Chr(34) & " type waveaudio alias MediaSound", Nothing, 0, IntPtr.Zero)
mciSendString("setaudio MediaSound volume to 1000", Nothing, 0, IntPtr.Zero)

' There should be a function here that make the sound start at the input value

mciSendString("play MediaSound", Nothing, 0, IntPtr.Zero)

End Sub

End Class
那么Winmm.dll中是否有一个函数可以在特定时间开始播放声音?

最佳答案

终于我找到了解决方案:
要在特定时间播放声音,我必须使用以下代码:
mciSendString(“从13000开始播放MediaSound,无,0,IntPtr.Zero)
在这种情况下,我从13秒开始播放
-------------------------------------------------- -------------------------------------------------- -------------------------
完整代码:

Imports System.Text
Imports System.Runtime.InteropServices

Public class SoundPlayer

<DllImport("winmm.dll")> Private Shared Function mciSendString(ByVal command As String, ByVal buffer As StringBuilder, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer
End Function

Public sub PlayMusicWithTime(SelectedTime as Integer)

mciSendString("open Sound1.wav type waveaudio alias MediaSound", Nothing, 0, IntPtr.Zero)
mciSendString("setaudio MediaSound volume to 1000", Nothing, 0, IntPtr.Zero)

mciSendString("play MediaSound from " & SelectedTime.toString, Nothing, 0, IntPtr.Zero)

End Sub

End Class

关于vb.net - 在特定时间播放声音-Winmm.dll-VB.Net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63583000/

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