none
How to play "Windows Navigation Start.wav" ?

Answers

  • make sure you have these statements at the top of your class

     

    Imports System

    Imports System.IO

    Imports System.Reflection

    Imports System.Runtime.InteropServices

    Imports System.Windows.Forms

    Public Class Sound

        '.....

    End Class

     

    hope it helps

    Wednesday, September 5, 2007 8:43 PM
  • Hi Rick. No need.

     

    My.Computer.Audio.Play("C:\Windows.0\Media\Windows Navigation Start.wav", AudioPlayMode.WaitToComplete)

     

    The Key is: WaitToComplete  - otherwise it loops endlessly annoyingly indiscernible.

     

    Where is my embedded wav. ?  ( I put it in the Resources - to know, how to refer to it, would be helpful)

    Wednesday, September 5, 2007 8:46 PM
  • Rick.

    I am back to the class - and I did what you say. Class is OK.

    Form1 is a problem.

     

    Dim sound As New Sound([Assembly].GetExecutingAssembly().GetManifestResourceStream("Windows navigation Start.wav"))

    sound.Play()

    Name Assembly is not declared.

    ----------------------------------------------------------------------------------------------------- 

    FROM MS

    This example uses a sound file named Chimes.wav.

    When you include the sound file as an embedded resource, you must return the

    resource stream for the file by prepending the assembly namespace to the original

    file name in the call to GetManifestResourceStream.

    Namespace: System.Reflection
    Assembly: mscorlib (in mscorlib.dll)

    Visual Basic (Declaration)
    Public Overridable Function GetManifestResourceStream ( _
    name As String _
    ) As Stream
    Visual Basic (Usage)
    Dim instance As Assembly
    Dim name As String
    Dim returnValue As Stream
    returnValue = instance.GetManifestResourceStream(name)

    ****************************************************************************

     

    Well now, the MS helpfiles are like a empty box of chocolete: unsatisfying.

     

    And the SOLUTION goes to the FORUM

     

    Include your preferred sound file into the Resources folder. Set its Property to Embedded.

    Include this line of code inside a ".Click" event and in this case, the music plays my preferred sound:

    Windows Navigation Start.wav

     

    My.Computer.Audio.Play(My.Resources.Windows_Navigation_Start, AudioPlayMode.WaitToComplete)

     

    By the way IntelliSense will offer the available choices after the typing gets to My.Resources.

    Great job MS. (Admiration for VB 2005 sprinkled over with a unhealthy dose of cynicism regarding the helpfiles)

    Thursday, September 6, 2007 3:18 PM

All replies

  • make sure you have these statements at the top of your class

     

    Imports System

    Imports System.IO

    Imports System.Reflection

    Imports System.Runtime.InteropServices

    Imports System.Windows.Forms

    Public Class Sound

        '.....

    End Class

     

    hope it helps

    Wednesday, September 5, 2007 8:43 PM
  • Hi Rick. No need.

     

    My.Computer.Audio.Play("C:\Windows.0\Media\Windows Navigation Start.wav", AudioPlayMode.WaitToComplete)

     

    The Key is: WaitToComplete  - otherwise it loops endlessly annoyingly indiscernible.

     

    Where is my embedded wav. ?  ( I put it in the Resources - to know, how to refer to it, would be helpful)

    Wednesday, September 5, 2007 8:46 PM
  • Hi , you can also use PlaySound Function From old APIs which contains alot of flages which is much helpFull . Following links containe information about it

    ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.WIN32COM.v10.en/multimed/htm/_win32_the_playsound_function.htm

     

    ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.WIN32COM.v10.en/multimed/htm/_win32_playsound.htm

     

    Following code will import it into your code

     

    Code Snippet

    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" ( _

    ByVal lpszName As String, _

    ByVal hModule As Long, _

    ByVal dwFlags As Long) As Long

     

     

    also you nust write this import in your code

    Imports System.Runtime.InteropServices

     

    then call it normally from within your code

     

     

    Thursday, September 6, 2007 11:55 AM
  • Rick.

    I am back to the class - and I did what you say. Class is OK.

    Form1 is a problem.

     

    Dim sound As New Sound([Assembly].GetExecutingAssembly().GetManifestResourceStream("Windows navigation Start.wav"))

    sound.Play()

    Name Assembly is not declared.

    ----------------------------------------------------------------------------------------------------- 

    FROM MS

    This example uses a sound file named Chimes.wav.

    When you include the sound file as an embedded resource, you must return the

    resource stream for the file by prepending the assembly namespace to the original

    file name in the call to GetManifestResourceStream.

    Namespace: System.Reflection
    Assembly: mscorlib (in mscorlib.dll)

    Visual Basic (Declaration)
    Public Overridable Function GetManifestResourceStream ( _
    name As String _
    ) As Stream
    Visual Basic (Usage)
    Dim instance As Assembly
    Dim name As String
    Dim returnValue As Stream
    returnValue = instance.GetManifestResourceStream(name)

    ****************************************************************************

     

    Well now, the MS helpfiles are like a empty box of chocolete: unsatisfying.

     

    And the SOLUTION goes to the FORUM

     

    Include your preferred sound file into the Resources folder. Set its Property to Embedded.

    Include this line of code inside a ".Click" event and in this case, the music plays my preferred sound:

    Windows Navigation Start.wav

     

    My.Computer.Audio.Play(My.Resources.Windows_Navigation_Start, AudioPlayMode.WaitToComplete)

     

    By the way IntelliSense will offer the available choices after the typing gets to My.Resources.

    Great job MS. (Admiration for VB 2005 sprinkled over with a unhealthy dose of cynicism regarding the helpfiles)

    Thursday, September 6, 2007 3:18 PM