Imports System.Text.RegularExpressions '正則表達(dá)式
Public Class 視頻播放器
Private 文件路徑 As String
Private Sub 視頻播放器_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.AllowDrop = True '支持文件拖拽
Me.Width = 920
Me.Height = 630
End Sub
Private Sub 視頻播放器_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
Try
If e.Data.GetDataPresent(DataFormats.FileDrop) = True Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub 視頻播放器_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
Try
Dim filepaht As String() = e.Data.GetData(DataFormats.FileDrop)
For Each File As String In filepaht
文件路徑 = File
'播放音樂(lè)文件
Dim 文件名 As String = 文件路徑.Substring(文件路徑.LastIndexOf("\") + 1)
If InStr(1, 文件路徑, ".flv", 1) Or InStr(1, 文件路徑, ".mp3", 1) Then
WebBrowser1.Url = New Uri("E:\usr\www\ckplayer6.4\demo.htm")
Else
MsgBox("不是支持的視頻文件,無(wú)法播放!")
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Refresh()
End Sub
End Class