5 Replies - 1569 Views - Last Post: 09 December 2012 - 09:52 AM Rate Topic: -----

#1 TheMightySpud  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 13-November 10

Controlling Windows Media player from seperate form.....

Posted 04 December 2012 - 02:00 PM

Hi all,

Been a while since I've done any vb.net, so please bear with me if this is a really silly mistake.

I'm building a media player, designed for a 2 monitor setup (monitor 1 is the 'display' screen and monitor 2 is a touchscreen display which I will be using to control the whole thing)

I have everything working perfectly except for one teeny weeny detail. The control buttons.

The Control Form appears on Monitor 2, on a seperate form to the Media Player control, which appears on Monitor 1.

This is the code that governs the buttons I'm using to control the Media Player

Private Sub btn_PlayPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Pause.Click, btn_Play.Click

        If frm_VideoPlayer.mp_player.playState = WMPLib.WMPPlayState.wmppsPlaying = True Then
            frm_VideoPlayer.mp_player.Ctlcontrols.pause()
            btn_Pause.Text = "Pause"

        ElseIf frm_VideoPlayer.mp_player.playState = WMPLib.WMPPlayState.wmppsPaused = True Then
            frm_VideoPlayer.mp_player.Ctlcontrols.play()
            btn_Pause.Text = "Play"
        End If

    End Sub



From what I remember/know of vb.net, this should work, but it doesn't unfortunately so I'm at a bit of a loss at to what's going on.

Would anyone be able to shed some light or point me in the right direction?

Thanks
TheMightySpud

Is This A Good Question/Topic? 0
  • +

Replies To: Controlling Windows Media player from seperate form.....

#2 TheMightySpud  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 13-November 10

Re: Controlling Windows Media player from seperate form.....

Posted 04 December 2012 - 02:23 PM

My apologies, I forgot to mention that I've set the Media Player control as Public.

TheMightySpud
Was This Post Helpful? 0
  • +
  • -

#3 Musashi822  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 28-November 12

Re: Controlling Windows Media player from seperate form.....

Posted 04 December 2012 - 03:57 PM

I copied and pasted your code, only changing the name of the form which I was using as the player form: Form1

I had 2 buttons on the second form, named exactly like you have posted. This works for me. However, since you are handling both button events on the same sub, no matter which one you click they are starting and stopping at the same time.

You might try separating the sub, only 1 for each buttons and try that.
Was This Post Helpful? 0
  • +
  • -

#4 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Controlling Windows Media player from seperate form.....

Posted 05 December 2012 - 12:55 AM

It should work IF player is paused or playing. If it's stopped, then if conditions will never be met, and code inside blocks never executed.
Was This Post Helpful? 0
  • +
  • -

#5 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Controlling Windows Media player from seperate form.....

Posted 05 December 2012 - 09:45 AM

Perhaps this will give you some ideas...

    Private Sub PlayerButtons_Click(sender As System.Object, e As System.EventArgs) Handles btnPause.Click, btnPlay.Click, btnStop.Click
        Dim btn As Button = CType(sender, Button)
        Select Case btn.Name
            Case "btnPlay"
                'Do Play stuff here
            Case "btnPause"
                'Do Pause stuff here
            Case "btnStop"
                'Do Stop stuff here
        End Select
    End Sub


Was This Post Helpful? 0
  • +
  • -

#6 TheMightySpud  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 13-November 10

Re: Controlling Windows Media player from seperate form.....

Posted 09 December 2012 - 09:52 AM

Thanks for the replies guys, sorry I've not responded sooner, not had much of a chance to work on this for the past week or so.

I've tried everything suggested above to no avail.

I've done some more checking and it seems the problem is that the form with the media player on is an instance of the actual form and not the form itself if that makes sense, but I can't seem to find a solution to accessing controls on an instanced form anywhere.

Would someone be able to point me in the right direction please?

Thanks
TheMightySpud
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1