Results 1 to 3 of 3

Thread: WCF Media Player in windows forms??

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    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:
    1. Public Class Form1
    2.  
    3.     Dim uc As System.Windows.Controls.MediaElement
    4.  
    5.     Private Sub btnLoadAndPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadAndPlay.Click
    6.         Dim host As New System.Windows.Forms.Integration.ElementHost
    7.         host.BackColor = Color.Black
    8.         host.Dock = DockStyle.Fill
    9.         Me.Controls.Add(host)
    10.         uc = New System.Windows.Controls.MediaElement
    11.         uc.UnloadedBehavior = Windows.Controls.MediaState.Manual
    12.         host.Child = uc
    13.         uc.Source = New Uri("c:\jukebox\music\0034615D380FF91A-12.mpg")
    14.     End Sub
    15.  
    16.     Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
    17.         uc.Stop()
    18.     End Sub
    19.  
    20. 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

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  3. #3

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: WCF Media Player in windows forms??

    whops i meant wpf - ill try that when i get home

    Thanks
    Kris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width