Solved

VB.NET 2005 - how to play a wav in an app for a windows mobile 5 application

Posted on 2006-10-20
4
852 Views
Last Modified: 2011-10-03
VB.NET 2005 - how to play a wav in an app for a windows mobile 5 application

Really struggling with this - I'm guessing the playsound wrapper isn't available..... anyone any ideas on the most efficient way of playing a wav on an ipaq?

Thanks,

Jc
0
Comment
Question by:misdevelopment
  • 2
4 Comments
 
LVL 2

Expert Comment

by:sivic82
ID: 17776137
By playsound wrapper I'm assuming your refering to my.Computer.Audio.Play("c:\my.wav")??
0
 

Author Comment

by:misdevelopment
ID: 17776610
Yes, we don't seem to have this available to us, even though we've looked to reference and import anything that looked like it might do the job.... I guessed that with it being for a mobile device that the classes weren't valid...
0
 
LVL 13

Accepted Solution

by:
newyuppie earned 500 total points
ID: 17778338
i've made a class that plays wav files asynchronously from your resources. you just need to insert the wav file in the sound resources, select Embedded in ResX for both the resource, and the file in the Solution Explorer too, in the resources folder.

Imports System
Imports System.Media
Imports System.Resources
Imports System.Reflection
Imports System.IO

Public Class Sound
    Public Shared Sub PlayWavResource(ByVal wav As String)

        ' get the namespace
        Dim strNameSpace As String = Assembly.GetExecutingAssembly().GetName().Name.ToString()
        Dim tempSpace As String = "CSCM"

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

        With New SoundPlayer(resourceStream)
            .Play()
        End With
    End Sub

End Class
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17778342
just replace
Dim tempSpace As String = "CSCM"

with
Dim tempSpace As String = [your root namespace]
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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