display video on 2 forms

ud2008

Well-known member
Joined
Jul 5, 2010
Messages
148
Programming Experience
Beginner
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.

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

Any idea?

Here is the code I use at this moment:
VB.NET:
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
 
Having one WMP form in each monitor works fine when I try it, both playing same video file and different video files, but I was only allowed one in fullscreen mode. I see previous versions of WMP has had some problems with multiple instances, I have version 11.
 
Having one WMP form in each monitor works fine when I try it, both playing same video file and different video files, but I was only allowed one in fullscreen mode. I see previous versions of WMP has had some problems with multiple instances, I have version 11.

I have version 12 (windows 7), I have wmp on each form, but it doesn't work with me.

Is the code I use correct?

Thanks
 
It looks fine to me, all I did was to set Url property.
 
What do you mean by set the Url property?

I use the openfiledialog.filename as Url.
That is fine, the FileName property returns the full path of the selected file.
 
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?
 
About fullScreen, see post 3 here: http://www.vbdotnetforums.com/windows-forms/23774-full-screen-wmp.html
The second is, that the audio and video on the second screen are not completely sync
That will be a struggle, since when you set url media is loaded, then you set second url and that media is loaded. Unless loading time is insignificant this can't happen at "same" time, and even if it did there would usually be small differences in loading the same media due to hdd and cpu usage. What you can try is to load media first in both player, then start them approx simultaneously. I haven't used the Wmp control much, but perhaps newMedia function can be used.
 
Back
Top