MSDN > フォーラム ホーム > Visual Basic General > Visual basic 2005 sound midi mp3 or wav files?
質問する質問する
 

回答済みVisual basic 2005 sound midi mp3 or wav files?

回答

  • 2008年6月28日 10:07John Anthony Oliver ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済みコードあり
    Hi,

    This is how to play WAVE *.wav files.

    Choose between;

    My.Computer.Audio.Play(ofd.FileName, AudioPlayMode.Background)

    or

    My.Computer.Audio.Play(ofd.FileName, AudioPlayMode.BackgroundLoop)

    or

    My.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 On

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim ofd As New OpenFileDialog
    ofd.InitialDirectory = "C:\Windows\media"
    ofd.Filter = "Wave files only|*.wav"
    Try
    ofd.ShowDialog()

    My.Computer.Audio.Play(ofd.FileName, AudioPlayMode.Background)

    Catch ex As Exception
    MessageBox.Show(ex.ToString)
    End Try

    End Sub
    End Class





    Regards,

    John

すべての返信