play wav file

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

31 Replies - 2724 Views - Last Post: 01 December 2012 - 03:11 PM Rate Topic: -----

#1 pjfatboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 30-November 12

play wav file

Posted 30 November 2012 - 11:04 AM

I'm trying to play a wav file in an app I'm working on. I did a Google search and this is what I came up with. could someone tell me why it doesn't work. The file is there I triple checked. Thanks
Dim appPath As String = Application.StartupPath()
If Alarmtxt.Text <> "" Then
    If CDate(Datelb.Text) = AlarmDTP.Value And Timelb.Text = Alarmtxt.Text Then
        My.Computer.Audio.Play(appPath & "\Alarm2.wav", AudioPlayMode.Background)
    End If
End If



Is This A Good Question/Topic? 0
  • +

Replies To: play wav file

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 767
  • Joined: 19-October 11

Re: play wav file

Posted 30 November 2012 - 11:20 AM

Set a breakpoint, and check the values.
Was This Post Helpful? 0
  • +
  • -

#3 pjfatboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 30-November 12

Re: play wav file

Posted 30 November 2012 - 11:42 AM

Yeah I did. When I checked the path, I looked several times and the file is there.

I am using the correct code to play the wav file right?
Was This Post Helpful? 0
  • +
  • -

#4 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 767
  • Joined: 19-October 11

Re: play wav file

Posted 30 November 2012 - 11:46 AM

Does the code enter line 4?
Was This Post Helpful? 0
  • +
  • -

#5 pjfatboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 30-November 12

Re: play wav file

Posted 30 November 2012 - 12:05 PM

It does.
Was This Post Helpful? 0
  • +
  • -

#6 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 767
  • Joined: 19-October 11

Re: play wav file

Posted 30 November 2012 - 12:26 PM

Then wav might be corrupted or something. Put it in a try catch block:
        Dim appPath As String = Application.StartupPath()
        If Alarmtxt.Text <> "" Then
            If CDate(Datelb.Text) = AlarmDTP.Value And Timelb.Text = Alarmtxt.Text Then
                Try
                    My.Computer.Audio.Play(appPath & "\Alarm2.wav", AudioPlayMode.Background)
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                End Try
            End If
        End If


This post has been edited by lucky3: 30 November 2012 - 12:27 PM

Was This Post Helpful? 0
  • +
  • -

#7 pjfatboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 30-November 12

Re: play wav file

Posted 30 November 2012 - 01:01 PM

Ok, it read line 5 and didn't catch any exception. The file is not corrupt, I can play the file with media player.
Was This Post Helpful? 0
  • +
  • -

#8 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: play wav file

Posted 30 November 2012 - 01:10 PM

View Postpjfatboy, on 30 November 2012 - 02:01 PM, said:

Ok, it read line 5 and didn't catch any exception. The file is not corrupt, I can play the file with media player.

I almost hate to ask this, but have you checked your volume control? I mean the full mixer control, not just the single control. There are a number of sound sources and destinations, and sometimes the one you need is set to the lowest it can go.
Was This Post Helpful? 0
  • +
  • -

#9 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 767
  • Joined: 19-October 11

Re: play wav file

Posted 30 November 2012 - 01:18 PM

Exactly my next question/proposition lar3ry ;)
Was This Post Helpful? 0
  • +
  • -

#10 pjfatboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 30-November 12

Re: play wav file

Posted 30 November 2012 - 01:22 PM

I just checked, they are all turned up. I have this same app I built in VB6 and it works fine there. I am trying to build it in VB.net 2010 and am having no luck getting this part of the app to work.
Was This Post Helpful? 0
  • +
  • -

#11 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 767
  • Joined: 19-October 11

Re: play wav file

Posted 30 November 2012 - 01:25 PM

Try to add this wav file to resources, and try with: My.Computer.Audio.Play(My.Resources.Alarm2, AudioPlayMode.Background)
Was This Post Helpful? 0
  • +
  • -

#12 pjfatboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 30-November 12

Re: play wav file

Posted 30 November 2012 - 01:47 PM

Ok, I tried that and that didn't work either. This is quite aggravating.
Was This Post Helpful? 0
  • +
  • -

#13 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 767
  • Joined: 19-October 11

Re: play wav file

Posted 30 November 2012 - 01:52 PM

Then.... Open up new forms project, add the file to the resources, and try:
Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Try
            My.Computer.Audio.Play(My.Resources.Alarm2, AudioPlayMode.Background)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class



Was This Post Helpful? 0
  • +
  • -

#14 pjfatboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 30-November 12

Re: play wav file

Posted 30 November 2012 - 02:05 PM

The same thing happened again. Does nothing. I can double click the file in Resources in the Solution Explorer and the file plays fine. #!*%
Was This Post Helpful? 0
  • +
  • -

#15 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 767
  • Joined: 19-October 11

Re: play wav file

Posted 30 November 2012 - 02:07 PM

If you'll do it quickly, I can take a look at it: zip the new project's solution, and upload it here. I'd like to test it on my comp.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3