Play multiple movies on windows form using VB.NET
By Perry
You can use this program as an example of playing multiple movies on the same windows form using VB.net
You can find complete code at http://www.eggheadcafe.com/fileupload/-698781408_MultiThreads.zip
Below I have given important function from this application. Start2() in flash.vb function plays the flash movie and Start2() in Html.vb plays slide show of the web pages. Enjoy...
In flash.vb
----------
Public Sub Start2()
If Not m_parentControl Is Nothing Then
If m_parentControl.InvokeRequired Then
' I must invoke, because I cannot add my webbrowser control to my panel !
m_parentControl.Invoke(New StartDelegate(AddressOf Start2))
Else
' I'm back in the main thread, and I don't want that !
If m_filename <> "" Then
Try
' Create new flash player control
Dim _flashPlayer As New AxShockwaveFlashObjects.AxShockwaveFlash()
' Set flash player in panel
m_parentControl.Controls.Add(_flashPlayer)
' Set properties of flash player
_flashPlayer.Width = m_parentControl.Width
_flashPlayer.Height = m_parentControl.Height
_flashPlayer.Location = New Point(0, 0)
_flashPlayer.Movie = m_dataFolder & "\Data\" & m_filename
_flashPlayer.Loop = True
_flashPlayer.Menu = False
_flashPlayer.Play()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
End If
End If
End Sub
In Html.vb
-----------
Public Sub Start2()
If Not m_parentControl Is Nothing Then
If m_parentControl.InvokeRequired Then
' I must invoke, because I cannot add my webbrowser control to my panel !
m_parentControl.Invoke(New StartDelegate(AddressOf Start2))
Else
' I'm back in the main thread, and I don't want that !
'MessageBox.Show(Threading.Thread.CurrentThread.Name)
Try
' Create new webbrowser control
Dim _webbrowser As New WebBrowser
Dim _url As String = m_url
_webbrowser.Width = m_parentControl.Width
_webbrowser.Height = m_parentControl.Height
_webbrowser.Location = New Point(0, 0)
_webbrowser.Url = New Uri(_url)
_webbrowser.ScrollBarsEnabled = False
_webbrowser.AllowNavigation = True
' Set webbrowser in panel
m_parentControl.Controls.Add(_webbrowser)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
End If
End Sub
Regards,
Megha
Popularity (1775 Views)