Sound on click?

Posts 1–11 of 11 · Page 1 of 1
Sound on click?
Hey guys, if i want my program to play a sound from a mp3 file when button 1 is clicked, how would i do that?

thanks
Use AxMediaPlayer control

[php]
AxMMControl1.Wait = True
AxMMControl1.FileName = "File Location \ Filename.extension"
AxMMControl1.Command = "Open"
AxMMControl1.Command = "Play"

[/php]

Or don't use an mp3 use a system sound

[php]
My.Computer.Audio.PlaySystemSound(soundname)
'Intelisense will show you a list of available system sounds
[/php]

Or you can load from the stream a wav file with SoundPlayer.LoadAsync

[php]
Try
player.SoundLocation = "File Location/File extension"

player.LoadAsync()

Catch ex As Exception
msgbox(ex.message)
End Try
[/php]

---Going by memory , you may need to

[php]
Imports system.media
[/php]

Unsure
Would I be able to test this?
Why not, GO ahead
Where do I find AxMedia?
Right Click Tools, Add Tools, Choose Com's tab
,scroll down the the bottom of the list and select Windows Media Player.

If it isn't there download WM9 SDK

Windows Media Player 9 SDK
Would the file location be C:/Music?
File location would be

either the actual location, like "C:\Music\Song.mp3"

Or (because usually it goes out to other users who may not have that folder, or it may be in a different folder, place the file in your application folder, and use)

Application.StartupPath
GJ! And sorry this is off topic, but how would i make a button disabled for a few seconds and then enabled when clicked?
Quote Originally Posted by Invidus View Post
GJ! And sorry this is off topic, but how would i make a button disabled for a few seconds and then enabled when clicked?
Axm = AxWindowsMediaPlayer

Code:
Public Class Form1

    Dim x As Integer

    Private Sub open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles open.Click
        Dim opf As New OpenFileDialog

        opf.ShowDialog()

        axm.URL = opf.FileName

    End Sub

    Private Sub play_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles play.Click
        axm.Ctlcontrols.play()
    End Sub

    Private Sub pause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pause.Click
        axm.Ctlcontrols.pause()
    End Sub

    Private Sub st0p_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles st0p.Click
        axm.Ctlcontrols.stop()
    End Sub

    Private Sub pausefor2s_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pausefor2s.Click
        timer1.enabled = True
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        x += 1

        If x = 1 Then
            pause_Click(sender, e)
        End If

        If x = 20 Then
            play_Click(sender, e)
            x = 0
            Timer1.Enabled = False
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Interval = 100
    End Sub
End Class
Ok thanks NextGen Good job.
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us