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
31 Replies - 731 Views - Last Post: 01 December 2012 - 03:11 PM
#1
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
Replies To: play wav file
#2
Re: play wav file
Posted 30 November 2012 - 11:20 AM
Set a breakpoint, and check the values.
#3
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?
I am using the correct code to play the wav file right?
#6
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
#7
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.
#8
Re: play wav file
Posted 30 November 2012 - 01:10 PM
pjfatboy, 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.
#9
Re: play wav file
Posted 30 November 2012 - 01:18 PM
Exactly my next question/proposition lar3ry
#10
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.
#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)
#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.
#13
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
#14
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. #!*%
#15
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.
|
|

New Topic/Question
Reply



MultiQuote




|