我已经发布了密码.........请帮助我处理声音 [英] I HAVE posted the codes ......please help me with my sound

查看:51
本文介绍了我已经发布了密码.........请帮助我处理声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何时候我尝试使用vb,net在计算机上播放wave文件时,当我单击按钮或窗体上的任何空格或将鼠标光标移到按钮上时,都会给我一个vshost.exe错误一段时间...当我的波浪声长度长时会冻结...


我在播放波形声音时尝试了不同的代码,但仍然给我vshost.exe错误...我真的需要帮助

这是声音类别的代码:

any time i try to play a wave file on my computer using vb,net, it gives me a vshost.exe error when i click on a button or any blank space on the form OR move the mouse cursor over a button for some period of time....it freezes when my wave sound length is long...


i have tried different codes on playing wave sound but it still gives me a vshost.exe error ...i really need help

"THIS IS THE CODE FOR A SOUND CLASS:

Imports System
Imports System.Runtime.InteropServices
Imports System.Resources
Imports System.IO
Public Class sound
    Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
         As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer

    Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
      As Byte(), ByVal hmod As Integer, ByVal flags As Integer) As Integer

    Public Const SND_SYNC = &H0 '' play synchronously 
    Public Const SND_ASYNC = &H9 '' play asynchronously 
    Public Const SND_MEMORY = &H4  ''Play wav in memory
    Public Const SND_ALIAS = &H10000 ''Play system alias wav 
    Public Const SND_NODEFAULT = &H2
    Public Const SND_FILENAME = &H20000 '' name is file name 
    Public Const SND_RESOURCE = &H40004 '' name is resource name or atom 

    Public Shared Sub PlayWaveFile(ByVal fileWaveFullPath As String)
        Try
            PlaySound(fileWaveFullPath, 0, SND_FILENAME)
        Catch
        End Try
    End Sub
   

    Public Shared Sub PlayWaveResource(ByVal WaveResourceName As String)
        
        '' get the namespace 
        Dim strNameSpace As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()

        '' get the resource into a stream
        Dim resourceStream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(strNameSpace + "." + WaveResourceName)
        If resourceStream Is Nothing Then Exit Sub

        '' bring stream into a byte array
        Dim wavData As Byte()
        ReDim wavData(CInt(resourceStream.Length))
        resourceStream.Read(wavData, 0, CInt(resourceStream.Length))

        '' play the resource
        PlaySound(wavData, 0&, SND_ASYNC Or SND_MEMORY)

    End Sub

    
    Public Shared Sub PlayWaveSystem(ByVal SystemWaveName As String)
        
        PlaySound(SystemWaveName, 0&, SND_ASYNC)

    End Sub
End Class



此代码也适用于单击按钮



THIS CODE IS ALSO FOR A BUTTON CLICK

 Public Class Frm_sound

    Inherits System.Windows.Forms.Form
    Friend WithEvents btnEmbe As System.Windows.Forms.Button
    Private Sub btnembed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs, Optional ByVal MaxLoops As Integer = 1) Handles btnEmbed.Click
        sound.PlayWaveResource("01 In The Morning Light.wav")
    End Sub
End Class

推荐答案

请参见以下文章在VB.NET中播放Waves [
See the following article Play Waves in VB.NET[^]


这篇关于我已经发布了密码.........请帮助我处理声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆