使用WebBrowser控件实现的视频播放器

Imports System.Text.RegularExpressions '正则表达式

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

'播放音乐文件

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("不是支持的视频文件,无法播放!")

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

你可能感兴趣的:(使用WebBrowser控件实现的视频播放器)