Visual Basic >
Visual Basic Forums
>
Visual Basic General
>
Visual basic 2005 sound midi mp3 or wav files?
Visual basic 2005 sound midi mp3 or wav files?
- How would I incorporate sound into a program? For instance a starting form then within the body of the program? Would I need to use a timer or is a midi file usable as it is?
Answers
- Hi,This is how to play WAVE *.wav files.Choose between;My.Computer.Audio.Play(ofd.FileName, AudioPlayMode.Background)orMy.Computer.Audio.Play(ofd.FileName, AudioPlayMode.BackgroundLoop)orMy.Computer.Audio.Play(ofd.FileName, AudioPlayMode.WaitToComplete)This works with Windows XP. :-) ;-)I'm not sure if VISTA still has a media folder containing WAVE files.Add 1 button to a FORM to try this code please.ofd.FileName here is the full path and filename returned from the OpenFileDialog.Option Strict OnPublic Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim ofd As New OpenFileDialogofd.InitialDirectory = "C:\Windows\media"ofd.Filter = "Wave files only|*.wav"Tryofd.ShowDialog()My.Computer.Audio.Play(ofd.FileName, AudioPlayMode.Background)Catch ex As ExceptionMessageBox.Show(ex.ToString)End TryEnd SubEnd ClassRegards,John
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 10:10 AMAdded an explanation.
- Marked As Answer byturkeygizzard Saturday, June 28, 2008 6:14 PM
All Replies
Hallo
bin gerade selbst auf der Suche, hab dabei diese Seite gefunden:
http://msdn.microsoft.com/de-de/library/bb978298.aspx
Mal sehen, ob ich die Beispiele (auf den Nachbarseiten) anwenden kann.
Gruß
Bingo_hb- Hi ALL,Here is a rough translation of the above using http://www.freetranslation.com/ >>>>___________________________________________________Hello Am just even on the search, found at the same time this side: http://msdn.microsoft.com/de-de/library/bb978298.aspxSee time whether I can use the examples (on the neighbor sides). Greeting Bingo_hb___________________________________________________Regards,John
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 9:24 AM....
- Hi Microsoft staff,Can we have this article in ENGLISH please?I've tried.>>and
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 9:33 AM....
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 9:34 AM....
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 9:36 AM....
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 9:39 AM....
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 9:40 AMDeleted a bit of extraneous text.
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 9:48 AMAdded another possible ENGLISH url link.
- Hi,This is how to play WAVE *.wav files.Choose between;My.Computer.Audio.Play(ofd.FileName, AudioPlayMode.Background)orMy.Computer.Audio.Play(ofd.FileName, AudioPlayMode.BackgroundLoop)orMy.Computer.Audio.Play(ofd.FileName, AudioPlayMode.WaitToComplete)This works with Windows XP. :-) ;-)I'm not sure if VISTA still has a media folder containing WAVE files.Add 1 button to a FORM to try this code please.ofd.FileName here is the full path and filename returned from the OpenFileDialog.Option Strict OnPublic Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim ofd As New OpenFileDialogofd.InitialDirectory = "C:\Windows\media"ofd.Filter = "Wave files only|*.wav"Tryofd.ShowDialog()My.Computer.Audio.Play(ofd.FileName, AudioPlayMode.Background)Catch ex As ExceptionMessageBox.Show(ex.ToString)End TryEnd SubEnd ClassRegards,John
- Edited byJohn Anthony Oliver Saturday, June 28, 2008 10:10 AMAdded an explanation.
- Marked As Answer byturkeygizzard Saturday, June 28, 2008 6:14 PM
- danke shein
I only know how to spaek a few words in German. Thankyou for your help but I wasn't able to view the library yet. Thanks anyway I appreciate all the help I can get!!!
~turkey~ - Thankyou John I appreciate your help. I'm really interested in midi files right now. I will look at the url you gave but it has to be in English!!! Thankyou so much for your help.
~turkey~


