如何在.net中播放声音?

编程入门 行业动态 更新时间:2024-10-20 16:36:36
本文介绍了如何在中播放声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我以前使用以下代码在VB6中播放声音: 公共声明功能sndPlaySound32 Lib" winmm的.dll" Alias" sndPlaySoundA" _ (ByVal lpszSoundName As String,ByVal uFlags As Long)As Long 调用sndPlaySound32(" c:\ WinNt \ Media \ ing.wav",0) 但是,不承认呼叫,并且生成语法错误。我只是想知道如何在中播放声音? 谢谢! CM

Hi, I used to use the following code to play sound in VB6: Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long call sndPlaySound32("c:\WinNt\Media\ding.wav", 0) However, don''t recognize "call", and generate a syntax error. I just wonder how to play sound in ? Thanks! CM

推荐答案

试试这个: ''// Win32API ''//两个整数args和return最初是Longs - .NET Integer = vb6 Long 声明函数PlaySound Lib" winmm.dll" _ Alias" PlaySoundA" (ByVal lpszName As String,_ ByVal hModule As Integer,_ ByVal dwFlags As Integer)As Integer Friend Sub PlayAudio(ByVal FileName As String) ''//调用win32api函数播放音频(wav)文件提醒 Dim retval As Integer retval = PlaySound(FileName,0,1) ''最后一个参数是SND_SYNC为整数 ''设置为0的值播放声音同步(等到声音结束之前 下一个播放) ''值设置为1播放声音异步(不等待播放下一个 声音) End Sub " CM" <厘米*** @ hotmail>在留言中写道 news:u6 ************** @ TK2MSFTNGP10.phx.gbl ... try this: ''//Win32API ''//Both integer args and return were originally Longs - .NET Integer = vb6 Long Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Integer, _ ByVal dwFlags As Integer) As Integer Friend Sub PlayAudio(ByVal FileName As String) ''//call win32api function to play audio (wav) file alert Dim retval As Integer retval = PlaySound(FileName, 0, 1) ''last param is SND_SYNC as integer ''value set to 0 plays sound Synchronously (waits until sound ends before playing next) ''value set to 1 plays sound Asynchronously (does not wait to play next sound) End Sub "CM" <cm***@hotmail> wrote in message news:u6**************@TK2MSFTNGP10.phx.gbl... 我曾经使用下面的代码在VB6中播放声音: Public Declare Function sndPlaySound32 Lib" winmm.dll"别名" sndPlaySoundA" _ (ByVal lpszSoundName As String,ByVal uFlags As Long)长期 调用sndPlaySound32(" c:\ WinNt \ Media \ ing.wav", 0) 然而,不识别call,并生成语法错误。我只是想知道如何在中播放声音? 谢谢! CM Hi, I used to use the following code to play sound in VB6: Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long call sndPlaySound32("c:\WinNt\Media\ding.wav", 0) However, don''t recognize "call", and generate a syntax error. I just wonder how to play sound in ? Thanks! CM

试试这个: ''// Win32API ''//整数args和return最初都是Longs - .NET整数= vb6 长 声明函数PlaySound Lib" winmm.dll" _ Alias" PlaySoundA" (ByVal lpszName As String,_ ByVal hModule As Integer,_ ByVal dwFlags As Integer)As Integer Friend Sub PlayAudio(ByVal FileName As String) ''//调用win32api函数播放音频(wav)文件提醒 Dim retval As Integer retval = PlaySound(FileName,0,1) ''最后一个参数是SND_SYNC为整数 ''设置为0的值播放声音同步(等到声音结束之前 下一个播放) ''值设置为1播放声音异步(不等待播放下一个 声音) End Sub " CM" <厘米*** @ hotmail>在留言中写道 news:u6 ************** @ TK2MSFTNGP10.phx.gbl ... try this: ''//Win32API ''//Both integer args and return were originally Longs - .NET Integer = vb6 Long Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Integer, _ ByVal dwFlags As Integer) As Integer Friend Sub PlayAudio(ByVal FileName As String) ''//call win32api function to play audio (wav) file alert Dim retval As Integer retval = PlaySound(FileName, 0, 1) ''last param is SND_SYNC as integer ''value set to 0 plays sound Synchronously (waits until sound ends before playing next) ''value set to 1 plays sound Asynchronously (does not wait to play next sound) End Sub "CM" <cm***@hotmail> wrote in message news:u6**************@TK2MSFTNGP10.phx.gbl... 我曾经使用下面的代码在VB6中播放声音: Public Declare Function sndPlaySound32 Lib" winmm.dll"别名" sndPlaySoundA" _ (ByVal lpszSoundName As String,ByVal uFlags As Long)长期 调用sndPlaySound32(" c:\ WinNt \ Media \ ing.wav", 0) 然而,不识别call,并生成语法错误。我只是想知道如何在中播放声音? 谢谢! CM Hi, I used to use the following code to play sound in VB6: Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long call sndPlaySound32("c:\WinNt\Media\ding.wav", 0) However, don''t recognize "call", and generate a syntax error. I just wonder how to play sound in ? Thanks! CM

非常感谢! CM Thank you very much! CM

更多推荐

如何在.net中播放声音?

本文发布于:2023-11-14 15:14:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587747.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声音   如何在   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!