display same video on 2 forms

delphibeginner
delphibeginner used Ask the Experts™
on
I've been trying to create a simple program with vb 2010 to play video's (when you use multiple screens) on the main screen (with controls) and the full screen (with no controls) on the second screen.

I get it to work that I can open the second screen and play a video, but the video is only played on the main screen and audio is played on the second screen (or nothing is played on the second screen).

I want to play the video on the main screen as well as on the second screen at the same time.

I use windows mediaplayer version 12 (see code)

Any idea?

Here is the code I use at this moment:
Public Class MainForm

    Private Sub ToolStripButton1_CheckStateChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.CheckStateChanged
        If ToolStripButton1.CheckState = CheckState.Checked Then
            Dim screen As Screen
            'Show second form on second screen
            screen = screen.AllScreens(1)
            SecondForm.StartPosition = FormStartPosition.Manual
            SecondForm.Location = screen.Bounds.Location + New Point(100, 100)
            SecondForm.Show()
            Me.Select()
        Else
            SecondForm.Close()
            ToolStripButton1.CheckState = CheckState.Unchecked
        End If
    End Sub

    Private Sub OpenVideoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenVideoToolStripMenuItem.Click
        OpenFileDialog1.ShowDialog()
        AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName
        SecondForm.AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        AxWindowsMediaPlayer1.Ctlcontrols.play()
        SecondForm.AxWindowsMediaPlayer1.Ctlcontrols.play()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        AxWindowsMediaPlayer1.Ctlcontrols.pause()
        SecondForm.AxWindowsMediaPlayer1.Ctlcontrols.pause()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        AxWindowsMediaPlayer1.Ctlcontrols.stop()
        SecondForm.AxWindowsMediaPlayer1.Ctlcontrols.stop()
    End Sub

    Private Sub Slider1_DecreaseButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Slider1.DecreaseButtonClick
        AxWindowsMediaPlayer1.settings.volume = AxWindowsMediaPlayer1.settings.volume - 10
    End Sub

    Private Sub Slider1_IncreaseButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Slider1.IncreaseButtonClick
        AxWindowsMediaPlayer1.settings.volume = AxWindowsMediaPlayer1.settings.volume + 10
    End Sub

    Private Sub Slider1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Slider1.MouseMove
        AxWindowsMediaPlayer1.settings.volume = Slider1.Value
    End Sub
End Class

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Ok strangly enough it works now, but I discovered 2 two small things (so it's not really solved yet), I want to play the second screen fullscreen, but I get the following error when calling the code where the mediaplayer.fullscreen = true:

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

The second is, that the audio and video on the second screen are not completely sync.

Any idea on this?
It works now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial