We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,913 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Pause a .wav audio

Hi there,
I'm doing a simp,e wav player as a school project. I know how to load, play and stop the audio but I don't know how to pause/resume it.
Here is my code

Public Class AudioPlayer
    Dim snd As Media.SoundPlayer = New Media.SoundPlayer
    Dim theFile As String = Nothing
    Dim sndCheck As Boolean = False
    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click

        Dim openDLG As OpenFileDialog = New OpenFileDialog


        Dim dlgResult As DialogResult = New DialogResult


        openDLG.CheckFileExists = True
        openDLG.Filter = "Wave Sound Files *.wav|*.wav"
        openDLG.Title = "Select the wave file you want to play."

        dlgResult = openDLG.ShowDialog()

        If dlgResult = Windows.Forms.DialogResult.OK Then

            theFile = openDLG.FileName
            snd.SoundLocation = theFile
            sndCheck = True

        Else

            Exit Sub

        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If sndCheck = True Then
            snd.Play()
        Else
            MessageBox.Show("Please select an audio file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        snd.Stop()
    End Sub
End Class

Any help please

2
Contributors
1
Reply
2 Days
Discussion Span
2 Months Ago
Last Updated
9
Views
Question
Answered
ringo_tech
Light Poster
28 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Well, SoundPlayer does not have an inbuilt pause/resume method, so you'd have to use another library if you're allowed to do so.

If I may, I would advice using DirectX to play the audio file, although a bit more complex, it has the functionality you need.

There is some more good reading here on your matter.

andreas.bjorn
Newbie Poster
9 posts since Feb 2013
Reputation Points: 0
Solved Threads: 4
Skill Endorsements: 0
Question Answered as of 2 Months Ago by andreas.bjorn

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0638 seconds using 2.78MB