• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 546
  • Last Modified:

play an embedded wave file


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!
  • 3
  • 2
1 Solution
peispudAuthor Commented:
i would really appreciate a working example.   I have already seen the example above.  Thanks though.
Mike TomlinsonMiddle School Assistant TeacherCommented:
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.
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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

Is this command native to vb.net?

So,   I am still searching for a solution.  Thanks so far though.
Mike TomlinsonMiddle School Assistant TeacherCommented:
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?
peispudAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now