play an embedded wave file

Posted on 2012-08-21
Last Modified: 2012-08-23

I am using VB.Net 2010

I would like to play an embedded wave file.  See attachment (wave file).

I have added the file to the project and changed the properties for this file for  "Build Action  = Embedded Resource".  I believe that I have this part right.  The coding though seems to be a problem.

This is driving me nuts.........

I would like to create a class to play embedded wave files.   I would like to instantiate an instance of this class and play audio from the main form.

I would really appreciate a working example.  Thanks!
Question by:peispud
    LVL 10

    Expert Comment


    Author Comment

    i would really appreciate a working example.   I have already seen the example above.  Thanks though.
    LVL 85

    Accepted Solution

    Click on Project --> Properties, then change to the Resources Tab.
    At the top, click the DropDown next to "Add Resource" and select "Add Existing File".
    Find and Add your .WAV file.
    Next, in the Properties Pane, change the "Persistence" to "Embedded in .resx".

    Now you can use code like this:
    Public Class Form1
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            My.Computer.Audio.Play(My.Resources.buzzer, AudioPlayMode.Background)
        End Sub
    End Class

    Open in new window

    In the IDE, when hitting the period "." after "My.Resources", your embedded .wav file name should appear in the options listed in the dropdown.

    Author Comment

    I've tried Idle_Mind's solution, but it the dropdown event does not seem to occur at all.

    Is this command native to

    So,   I am still searching for a solution.  Thanks so far though.
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    So when you type "My.Resources", and then hit the period, you don't get a dropdown listing your embedded resources?

    It's definitely native to VB.Net.  What type of Project did you start with?

    Author Comment

    I am using Visual Basic 2010 and my project was started with a windows form.

    I think the problem occured when I renamed my project.   I will close this question now with many  thanks.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now