AxWindowsMediaPlayer1.Ctlcontrols.play()au Private Sub f_TitreChange.
Public Class Form2 Event TitreChange(ByVal titre As String) Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged RaiseEvent TitreChange(ListBox1.Text) End Sub End Class
Public Class Form1 Dim WithEvents f As New Form2 Private Sub f_TitreChange(ByVal titre As String) Handles f.TitreChange AxWindowsMediaPlayer1.URL = titre End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load f.Show() End Sub End Class
Public Class Form3 Event TitreChange(ByVal titre As String) Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged RaiseEvent TitreChange(ListBox1.Text) End Sub End Class
Public Class Form1 Dim WithEvents f As New Form3 Private Sub f_TitreChange(ByVal titre As String) Handles f.TitreChange AxWindowsMediaPlayer1.URL = titre End Sub
'Boutton play Private Sub PictureBox6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.Click If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPaused Then AxWindowsMediaPlayer1.Ctlcontrols.play() Timer1.Enabled = True Label1.Text = AxWindowsMediaPlayer1.status Else AxWindowsMediaPlayer1.Ctlcontrols.play() Timer1.Enabled = True Label1.Text = "Lecture" End If End Sub
'Bouton ouvrir un dossier Private Sub PictureBox26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox26.Click Me.FolderBrowserDialog1.ShowNewFolderButton = False Me.FolderBrowserDialog1.Description = _ "Selectionnez un dossier contenant des fichiers audio" Label1.Text = "Ouvrir un dossier" If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Dim x As String = FolderBrowserDialog1.SelectedPath Dim di As New IO.DirectoryInfo(x) Dim FileMp3 As IO.FileInfo() = di.GetFiles("*.mp3") Dim FileWave As IO.FileInfo() = di.GetFiles("*.wav") Dim FileWma As IO.FileInfo() = di.GetFiles("*.wma") Dim FileAcc As IO.FileInfo() = di.GetFiles("*.acc") For Each File As IO.FileInfo In FileMp3 f.ListBox1.Items.Add(File.Name) f.ListBox1.SelectedItem = f.ListBox1.Items(0) Next For Each File As IO.FileInfo In FileWave f.ListBox1.Items.Add(File.Name) f.ListBox1.SelectedItem = f.ListBox1.Items(0) Next For Each File As IO.FileInfo In FileWma f.ListBox1.Items.Add(File.Name) f.ListBox1.SelectedItem = f.ListBox1.Items(0) Next For Each File As IO.FileInfo In FileAcc f.ListBox1.Items.Add(File.Name) f.ListBox1.SelectedItem = f.ListBox1.Items(0) Next Timer1.Enabled = False f.Show() End If End Sub
'Ouvrir un fichier audio Private Sub PictureBox11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox11.Click OpenFileDialog1.InitialDirectory = System.Environment.SpecialFolder.CommonMusic OpenFileDialog1.FileName = "" OpenFileDialog1.Multiselect = True OpenFileDialog1.Filter = "Audio Files (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc" Label1.Text = "Ouvrir un fichier" If OpenFileDialog1.ShowDialog = DialogResult.OK Then Dim f As String = Path.GetFileNameWithoutExtension(OpenFileDialog1.FileName) Label3.Text = f AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName AxWindowsMediaPlayer1.Ctlcontrols.play() Timer1.Enabled = True Label1.Text = "Lecture fichier audio" End If End Sub
rien n'est lu par le player sur Form1
f.ListBox1.Items.Add(File.FullName)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionf.ListBox1.Items.Add(File.Name)pour que les fichiers s'affichent sans le chemin du repertoire.
Dim g As String = Path.GetFileNameWithoutExtension(FolderBrowserDialog1.SelectedPath) Label3.Text = g
'Ouvrir un fichier audio Private Sub PictureBox11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox11.Click OpenFileDialog1.InitialDirectory = System.Environment.SpecialFolder.CommonMusic OpenFileDialog1.FileName = "" OpenFileDialog1.Multiselect = True OpenFileDialog1.Filter = "Audio Files (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp2;*.mp3;*.adts;*.adt;*.acc" Label1.Text = "Ouvrir un fichier" If OpenFileDialog1.ShowDialog = DialogResult.OK Then Dim g As String = Path.GetFileNameWithoutExtension(OpenFileDialog1.FileName) Label3.Text = g AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName AxWindowsMediaPlayer1.Ctlcontrols.play() Timer1.Enabled = True Label1.Text = "Lecture fichier audio" For Each track As String In OpenFileDialog1.FileNames f.ListBox1.Items.Add(track) Next End If End Sub
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then '... End If End Sub
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Then f.ListBox1.SelectedIndex = f.ListBox1.SelectedIndex + 1 Me.AxWindowsMediaPlayer1.URL = f.ListBox1.SelectedItem Me.AxWindowsMediaPlayer1.Ctlcontrols.play() End If ' Display the bitRate when the player is playing. Select Case AxWindowsMediaPlayer1.playState ' If WMPPlayState is Stopped, Paused, ScanForward, ScanReverse, Waiting, MediaEnded ' or Transitioning then stop the timer. Case 1 Case 2 Case 3 ' Play State WMPLib.WMPPlayState.wmppsPlaying 3 Case 4 Case 5 Case 7 Case 8 Case 9 Timer.Stop() ' If WMPPlayState is Playing or Buffering then set the timer interval and start the timer. Case Else Timer.Interval = 1000 Timer.Start() End Select End Sub
Me.AxWindowsMediaPlayer1.URL = f.ListBox1.SelectedItem Me.AxWindowsMediaPlayer1.Ctlcontrols.play()
Private Sub f_TitreChange(ByVal titre As String) Handles f.TitreChange AxWindowsMediaPlayer1.URL = titre AxWindowsMediaPlayer1.Ctlcontrols.play() End Sub
AxWindowsMediaPlayer1.Ctlcontrols.play()pour placer un point d'arrêt.
AxWindowsMediaPlayer1.Ctlcontrols.stop AxWindowsMediaPlayer1.url = titre AxWindowsMediaPlayer1.Ctlcontrols.play()