Play flv file in VB.NET Form

Hi I have movie trailer in FLV format (9MB) I would like to play it in VB.NET WIndows Form ...
Who is Participating?
Bob LearnedCommented:
There are resources to be found, like this CodeProject article, that describes what you need to do to display a FLV file.

Fun with C# and the Flash Player 8 External API
Imports System 
Imports System.Drawing 
Imports System.Collections 
Imports System.ComponentModel 
Imports System.Windows.Forms 
Imports System.Data 
Imports System.IO 
Imports System.Xml 
Imports AxShockwaveFlashObjects 

Namespace Vml.FLVPlayer 
    ''' <summary> 
    ''' Summary description for Form1. 
    ''' </summary> 
    Public Class FLVPlayer 
        Inherits System.Windows.Forms.Form 
        Private statusbar As StatusBar 
        Private fileNameStatusBarPanel As StatusBarPanel 
        Private videoPlaceholder As System.Windows.Forms.Panel 
        Private openVideo As System.Windows.Forms.Button 
        Private openVideoDialog As System.Windows.Forms.OpenFileDialog 
        Private flashPlayer As AxShockwaveFlashObjects.AxShockwaveFlash 
        ''' <summary> 
        ''' Required designer variable. 
        ''' </summary> 
        Private components As System.ComponentModel.Container = Nothing 
        Public Sub New() 
            ' Required for Windows Form Designer support 
                flashPlayer.LoadMovie(0, Application.StartupPath & "\player.swf") 
                AddHandler flashPlayer.FlashCall, AddressOf flashPlayer_FlashCall 
            Catch ex As Exception 
                ExceptionUtilities.DisplayException("Unable to load SWF video player, please verify you have Flash Player 8 installed and try again.") 
            End Try 
        End Sub 
        Public Sub New(ByVal moviePath As String) 
        End Sub 
        ''' <summary> 
        ''' Clean up any resources being used. 
        ''' </summary> 
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) 
            If disposing Then 
                If components IsNot Nothing Then 
                End If 
            End If 
        End Sub 
        #Region "Windows Form Designer generated code" 
        ''' <summary> 
        ''' Required method for Designer support - do not modify 
        ''' the contents of this method with the code editor. 
        ''' </summary> 
        Private Sub InitializeComponent() 
            Dim resources As New System.Resources.ResourceManager(GetType(FLVPlayer)) 
            Me.openVideo = New System.Windows.Forms.Button() 
            Me.openVideoDialog = New System.Windows.Forms.OpenFileDialog() 
            Me.statusbar = New System.Windows.Forms.StatusBar() 
            Me.fileNameStatusBarPanel = New System.Windows.Forms.StatusBarPanel() 
            Me.videoPlaceholder = New System.Windows.Forms.Panel() 
            Me.flashPlayer = New AxShockwaveFlashObjects.AxShockwaveFlash() 
            DirectCast((Me.fileNameStatusBarPanel), System.ComponentModel.ISupportInitialize).BeginInit() 
            DirectCast((Me.flashPlayer), System.ComponentModel.ISupportInitialize).BeginInit() 
            ' openVideo 
            Me.openVideo.FlatStyle = System.Windows.Forms.FlatStyle.System 
            Me.openVideo.Location = New System.Drawing.Point(8, 272) 
            Me.openVideo.Name = "openVideo" 
            Me.openVideo.Size = New System.Drawing.Size(88, 23) 
            Me.openVideo.TabIndex = 1 
            Me.openVideo.Text = "Open..." 
            AddHandler Me.openVideo.Click, AddressOf Me.openVideo_Click 
            ' statusbar 
            Me.statusbar.Location = New System.Drawing.Point(0, 298) 
            Me.statusbar.Name = "statusbar" 
            Me.statusbar.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.fileNameStatusBarPanel}) 
            Me.statusbar.ShowPanels = True 
            Me.statusbar.Size = New System.Drawing.Size(338, 22) 
            Me.statusbar.SizingGrip = False 
            Me.statusbar.TabIndex = 4 
            ' fileNameStatusBarPanel 
            Me.fileNameStatusBarPanel.Text = "File not loaded" 
            Me.fileNameStatusBarPanel.ToolTipText = "The file currently loaded" 
            Me.fileNameStatusBarPanel.Width = 810 
            ' videoPlaceholder 
            Me.videoPlaceholder.BackColor = System.Drawing.Color.Black 
            Me.videoPlaceholder.Location = New System.Drawing.Point(8, 8) 
            Me.videoPlaceholder.Name = "videoPlaceholder" 
            Me.videoPlaceholder.Size = New System.Drawing.Size(320, 240) 
            Me.videoPlaceholder.TabIndex = 6 
            ' flashPlayer 
            Me.flashPlayer.ContainingControl = Me 
            Me.flashPlayer.Enabled = True 
            Me.flashPlayer.Location = New System.Drawing.Point(0, 0) 
            Me.flashPlayer.Name = "flashPlayer" 
            Me.flashPlayer.OcxState = DirectCast((resources.GetObject("flashPlayer.OcxState")), System.Windows.Forms.AxHost.State) 
            Me.flashPlayer.Size = New System.Drawing.Size(40, 24) 
            Me.flashPlayer.TabIndex = 0 
            ' FLVPlayer 
            Me.AccessibleName = "FLVPlayer" 
            Me.AllowDrop = True 
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) 
            Me.ClientSize = New System.Drawing.Size(338, 320) 
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle 
            Me.Icon = DirectCast((resources.GetObject("$this.Icon")), System.Drawing.Icon) 
            Me.MaximizeBox = False 
            Me.Name = "FLVPlayer" 
            Me.Text = "FLVPlayer" 
            AddHandler Me.DragDrop, AddressOf Me.FLVPlayer_DragDrop 
            AddHandler Me.DragEnter, AddressOf Me.FLVPlayer_DragEnter 
            DirectCast((Me.fileNameStatusBarPanel), System.ComponentModel.ISupportInitialize).EndInit() 
            DirectCast((Me.flashPlayer), System.ComponentModel.ISupportInitialize).EndInit() 
        End Sub 
        #End Region 
        Private Sub openVideo_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
            openVideoDialog = New OpenFileDialog() 
            openVideoDialog.Filter = "*.flv|*.flv" 
            openVideoDialog.Title = "Select a Flash Video file..." 
            openVideoDialog.Multiselect = False 
            openVideoDialog.RestoreDirectory = True 
            If openVideoDialog.ShowDialog() = DialogResult.OK Then 
            End If 
        End Sub 
        Private Sub LoadVideo(ByVal videoPath As String) 
            fileNameStatusBarPanel.Text = videoPath 
            flashPlayer.CallFunction("<invoke name=""loadAndPlayVideo"" returntype=""xml""><arguments><string>" & videoPath & "</string></arguments></invoke>") 
        End Sub 
        Private Sub FLVPlayer_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) 
            Dim files As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), String()) 
            If fileNameStatusBarPanel.Text <> files(0) Then 
            End If 
        End Sub 
        Private Sub FLVPlayer_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) 
            If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then 
                e.Effect = DragDropEffects.All 
            End If 
        End Sub 
        ' private void btnUrl_Click(object sender, System.EventArgs e) 
        ' { 
        ' UrlDialog urlForm = new UrlDialog(); 
        ' if(urlForm.ShowDialog(this) == DialogResult.OK) 
        ' { 
        ' if(urlForm.Url != null && urlForm.Url.Length > 0) 
        ' { 
        ' LoadVideo(urlForm.Url); 
        ' } 
        ' } 
        ' } 
        Public Sub ResizePlayer(ByVal width As Integer, ByVal height As Integer) 
            flashPlayer.Width = width 
            flashPlayer.Height = height 
            videoPlaceholder.Width = width 
            videoPlaceholder.Height = height 
        End Sub 
        Private Sub flashPlayer_FlashCall(ByVal sender As Object, ByVal e As _IShockwaveFlashEvents_FlashCallEvent) 
            Dim document As New XmlDocument() 
            ' Since I have only one call back I just grab the arguments and call 
            ' the function. This needs to be made much more flexible when there are 
            ' multiple call backs going back and forth 
            Dim list As XmlNodeList = document.GetElementsByTagName("arguments") 
            ResizePlayer(Convert.ToInt32(list(0).FirstChild.InnerText), Convert.ToInt32(list(0).ChildNodes(1).InnerText)) 
        End Sub 
    End Class 
End Namespace

Open in new window

Meir RivkinFull stack Software EngineerCommented:
if Flash is installed on your pc u can use the COM component "Shockwave Flash Object".
just right click your toolbox, click Add/Remove Items and tick the "Shockwave Flash Object" in the COM Components" list.

Meir RivkinFull stack Software EngineerCommented:
_ColdFire_Author Commented:
sedgwick: your solutions seems to be much easier , i accepted TheLearnedOne's solution because there was no others. When I'm using your method, i get an error when launching application. Microsoft saying:

The program you were trying to install or use requires the latest version of Adobe Flash Player.

To solve this problem, uninstall and then reinstall Adobe Flash Player by following these steps in the order given:
Additional information for 64-bit browser users

Adobe Flash Player is not currently supported in 64-bit browsers. You can run Adobe Flash Player in a 32-bit browser running on a 64-bit operating system. For more information, see the TechNote on the Adobe Systems Inc. website:

I'm using Windows 7 x64, should I do something for program to use 32bit explorer?
_ColdFire_Author Commented:
it doesnt play flv files , just flash.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.