WCF Media Player in windows forms??
I thought that I would make a WCF based media player in a standard windows form so I whipped up the following:
vb Code:
Public Class Form1
Dim uc As System.Windows.Controls.MediaElement
Private Sub btnLoadAndPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadAndPlay.Click
Dim host As New System.Windows.Forms.Integration.ElementHost
host.BackColor = Color.Black
host.Dock = DockStyle.Fill
Me.Controls.Add(host)
uc = New System.Windows.Controls.MediaElement
uc.UnloadedBehavior = Windows.Controls.MediaState.Manual
host.Child = uc
uc.Source = New Uri("c:\jukebox\music\0034615D380FF91A-12.mpg")
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
uc.Stop()
End Sub
End Class
The video loads ok when the btnLoadAndPlay button is pressed
However the uc.Stop in the btnStop_Click does not stop the video any ideas why this may be happening?
Thanks in advance
Kris
Re: WCF Media Player in windows forms??
Try this: (and just for the record, it is WPF - Windows Presentation Foundation). WCF is Windows Communication Foundation.
Code:
Dim uc As System.Windows.Controls.MediaElement
Private Sub btnLoadAndPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadAndPlay.Click
Dim host As New System.Windows.Forms.Integration.ElementHost
host.BackColor = Color.Black
host.Dock = DockStyle.Fill
Me.Controls.Add(host)
uc = New System.Windows.Controls.MediaElement
uc.UnloadedBehavior = Windows.Controls.MediaState.Manual
uc.LoadedBehavior = Windows.Controls.MediaState.Manual
host.Child = uc
uc.Source = New Uri("c:\jukebox\music\0034615D380FF91A-12.mpg")
uc.Play()
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
uc.Stop()
End Sub
End Class
Re: WCF Media Player in windows forms??
whops i meant wpf - ill try that when i get home
Thanks
Kris