How might I play an MP3 File?

Biohazard

Well-known member
Joined
Nov 23, 2009
Messages
52
Programming Experience
5-10
My trouble comes from a lot of websites actually
One tells me to load the Microsoft Media Control
Going to Tools>Options>Controls tab but there is no such thing
Another tells me to load the MP3 with an external application by doing calling the Process.Start Class but I don't want to use more ram than necessary and I want to repeat the sound.

Here is the code I need to integrate the MP3 Control with
VB.NET:
Private Function DoTheJob()
        Dim StrWord As String = ""
        Dim WordNumber As Integer = 0
        NextWord(StrWord, WordNumber)
        Label1.Text = StrWord
        If WordNumber = 1 Then
            PictureBox1.Image = My.Resources._1195422442280900362ArtFavor_Mom_holding_childs_hand_svg_med
        End If
        If WordNumber = 2 Then
            PictureBox1.Image = My.Resources._1195422165776583552ArtFavor_Dad_holding_daughters_hand_svg_med
        End If
        If WordNumber = 3 Then
            PictureBox1.Image = My.Resources._119498555124689266sedia_in_legno_architett_01_svg_med
        End If
        If WordNumber = 4 Then
            PictureBox1.Image = My.Resources.MOS_001_2
        End If
        If WordNumber = 5 Then
            PictureBox1.Image = My.Resources._11971013331885495170jilagan_Spoon_svg_med
        End If
        Return 0
    End Function

Now where I want the code to function is:
If WordNumber = 1 Then Play MP3.1
If WordNumber = 2 Then Play MP3.2
..ETC

Any suggestions
 
Update:
Now I have an issue where when this function is called the first time it plays the MP3 but if it is called again lets say buy a timer interval, the picture changes like normal but the mp3's url wont nor will it play

VB.NET:
 Private Function DoTheJob()

        Dim StrWord As String = ""
        Dim WordNumber As Integer = 0
        NextWord(StrWord, WordNumber)
        Label1.Text = StrWord
        If WordNumber = 1 Then
            PictureBox1.Image = My.Resources._1195422442280900362ArtFavor_Mom_holding_childs_hand_svg_med
            AxWindowsMediaPlayer2.URL = ""
            AxWindowsMediaPlayer2.URL = Application.StartupPath & "\Mommy.mp3"

        End If
        If WordNumber = 2 Then
            PictureBox1.Image = My.Resources._1195422165776583552ArtFavor_Dad_holding_daughters_hand_svg_med
            AxWindowsMediaPlayer2.URL = ""
            AxWindowsMediaPlayer2.URL = Application.StartupPath & "\Daddy.mp3"
            AxWindowsMediaPlayer2.Refresh()
        End If
        If WordNumber = 3 Then
            PictureBox1.Image = My.Resources._119498555124689266sedia_in_legno_architett_01_svg_med
            AxWindowsMediaPlayer2.URL = ""
            AxWindowsMediaPlayer2.URL = Application.StartupPath & "\Chair.mp3"
            AxWindowsMediaPlayer2.Refresh()
        End If
        If WordNumber = 4 Then
            PictureBox1.Image = My.Resources.MOS_001_2
            AxWindowsMediaPlayer2.URL = ""
            AxWindowsMediaPlayer2.URL = Application.StartupPath & "\Cup.mp3"
            AxWindowsMediaPlayer2.Refresh()
        End If
        If WordNumber = 5 Then
            PictureBox1.Image = My.Resources._11971013331885495170jilagan_Spoon_svg_med
            AxWindowsMediaPlayer2.URL = ""
            AxWindowsMediaPlayer2.URL = Application.StartupPath & "\Spoon.mp3"
            AxWindowsMediaPlayer2.Refresh()
        End If
        Return 0
    End Function
 
Okay gonna look dumb on me
But I found the problem it was working the entire time

The issue was, I never updated the timer to use the function DoTheJob
Instead I had the entire code for dothejob (minus the MP3 part)

Hahahaha
 
Thank for posting what happened...if it happened to you, you can bet it will happen to someone else, and this thread might help them out. ;)
 
Back
Top