65.9K
CodeProject 正在变化。 阅读更多。
Home

嵌入网络视频

starIconstarIconemptyStarIconemptyStarIconemptyStarIcon

2.00/5 (3投票s)

2007年12月12日

CPOL
viewsIcon

46391

downloadIcon

1230

在桌面应用程序中嵌入网络视频。

Screenshot - 1.JPG

引言

这个示例将允许您将基于网络的 Flash 视频嵌入/流式传输到应用程序中。

背景

首先,我们需要将“Microsoft Web Browser”控件添加到“工具箱”中(默认的“WebBrowser”控件可以使用,但对于这个项目来说有点小问题。:-(

要将 WebBrowser 控件添加到工具箱中,请打开“工具”菜单并选择“选择工具箱项...”。

选择“COM 组件”选项卡,选中“Microsoft Web Browser”旁边的复选框,然后单击“确定”。

新的 Microsoft WebBrowser 现在应该已添加到工具箱中。

Using the Code

Public Class Form1
'Start Button Click Event

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

'Clear out the RTB to receive the new HTML 
RichTextBox1.Text = ""

'Create the HTML with the Embedded code, from the Clipboard
RichTextBox1.AppendText("<html>" & _
ControlChars.NewLine & "<body>" & _
ControlChars.NewLine & My.Computer.Clipboard.GetText & _
ControlChars.NewLine & "</body>" & _
ControlChars.NewLine & "</html>")

'Save/Overwrite the HTML file
RichTextBox1.SaveFile(Application.StartupPath & "\321.html", _
	RichTextBoxStreamType.PlainText)

'Show the WaitCursor
Windows.Forms.Cursor.Current = Cursors.WaitCursor

'Load the new HTML file into the browser, so we can watch the video in our app.
AxWebBrowser1.Navigate(Application.StartupPath & "\321.html")

'Show the default Cursor
Windows.Forms.Cursor.Current = Cursors.Default
End Sub

'Refresh Button Click Event
Private Sub Button2_Click(ByVal sender As System.Object, _
	ByVal e As System.EventArgs) Handles Button2.Click

'Refresh the browser, also stops/rewind the video
AxWebBrowser1.Refresh()
End Sub
End Class

关注点

注意:当单击“开始”按钮时,应用程序会创建/覆盖一个新文件(Application.StartupPath & "\321.html”)。

然后,应用程序在 Web 浏览器中加载新的 HTML 文件,单击 Flash 视频上的“播放”按钮。

HTML 文件可以在“Embed_YouTube\bin\Debug”文件夹中找到。

历史

  • 2007 年 12 月 12 日:初始发布
© . All rights reserved.