0
我開發的視頻播放器與WPF(在VB)播放音頻與MediaElement的散發WPF
我已經創建了一個MediaElement的,列表框,「下一步」按鈕,
然後開始通過閱讀打列表框,
並使用「下一步」跳到下一個音頻/視頻。
在「MediaEnded」事件中,我只是將所有代碼複製到「下一步」按鈕。
現在,問題來了,
假設列表框有四個音頻(MP3播放), 「test1.mp3」, 「test2.mp3」,......
現在播放的是「test1.mp3」,我按「下一步」按鈕,然後現在播放的是「test2.mp3」。
然而,當我只是讓「test1.mp3」戲完成,我的播放器不能播放「test2.mp3」,
它起着「test3.mp3」或其他隨機的。
像「MediaEnded」事件這種情況被處理了很多次。
Private Sub MediaElement1_MediaEnded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MediaElement1.MediaEnded
nextmedia()
End Sub
Private Sub nextmedia()
Try
'pi is play index, start from 1, 0 is non playing
If pi <> 0 Then
If pi = ListBox_temp.Items.Count Then
Dim filename As String = ListBox_temp.Items.Item(0).ToString
MediaElement1.Source = New Uri(filename)
pi = 1
Else
Dim filename As String = ListBox_temp.Items.Item(pi).ToString
MediaElement1.Source = New Uri(filename)
pi = pi + 1
End If
End If
Catch ex As Exception
End Try
Window1.Title = "Video Sampler - " + CStr(pi) + ". " + CStr(ListBox1.Items.Item(pi - 1))
End Sub
誰能幫我....
「誰能幫助我」:沒有人,除非你發佈一些代碼... –
對不起,我補充說。 –