locked
wmp trackbar RRS feed

  • Question

  • Hi all

    I am trying to figure out how to make a trackbar move in sync with my wmp player

    cannot figure out the duration setting....

    I would also like to make a volume trackbar....

    any help appreciated

     

    dim duration as string = wmp.currentmedia.duration.......???????

     

     

    Me.TrackBar2.BackColor = Color.LavenderBlush

    Me.TrackBar2.Location = New System.Drawing.Point(0, 130)

    Me.TrackBar2.Margin = New System.Windows.Forms.Padding(3, 3, 3, 1)

    Me.TrackBar2.Maximum = 100

    Me.TrackBar2.Name = "TrackBar2"

    Me.TrackBar2.Size = New System.Drawing.Size(358, 10)

    'Me.TrackBar2.TabIndex = 13

    Me.TrackBar2.TickFrequency = 1

    Me.TrackBar2.TickStyle = System.Windows.Forms.TickStyle.Nne

     

    Me.TrackBar2.Value = ???????

     

    tia

    Thursday, August 30, 2007 7:50 AM

Answers

  • Like this maybe with trackbar2 min = 0 and max = 100 and maybe the value in the designer at 50 to start .

     

    Code Snippet

     

    Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick

    TrackBar1.Maximum = player.currentMedia.duration

    TrackBar1.Value = player.Ctlcontrols.currentPosition

    tracklabel.Text = TrackBar1.Maximum - TrackBar1.Value

    player.settings.volume = TrackBar2.Value

    End Sub

     

     

    Thursday, August 30, 2007 10:54 AM
  • thanks bdbodger

    I done it this way

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll

    wmp.settings.volume = TrackBar1.Value

    End Sub

    ..........................................................

     

    Private Sub T_Tick(ByVal sender As Object, _

    ByVal e As System.EventArgs) Handles T.Tick

    TrackBar1.Minimum = 0

    TrackBar1.Maximum = 100

    TrackBar1.Value = wmp.settings.volume

    end sub

     

    this seems to work nicely

    cheers

    Thursday, August 30, 2007 11:39 AM
  •  

    You wouldn't need a timer to set trackbar1 if it is for volume since it's value won't change a timer would be good for the position in the song since it changes as the song plays . The minimum and maximum can be set in the designer and trackbar1.value = wmp.settings.volume won't do anything anyway since it will still be the same as when you set it in the scroll event . All you would need to do a volume slider is the scroll event . I only added to the timer since it was easier than makeing a new sub and the timer was ticking at the default setting of  1/10 of a second or 100 miliseconds anyway . So that timer is pointless except maybe when the form loads then it will set the trackbar to 100 or what ever the default is .
    Thursday, August 30, 2007 12:41 PM

All replies

  • Why not using the progress bar

    it's easier

     

    Thursday, August 30, 2007 8:14 AM
  • thanks omar, but I want trackbar 

     

    Thursday, August 30, 2007 8:19 AM
  • ok...I figured out the duration....working great

    just need the volume trackbar now

    any help welcome

    tia

    Thursday, August 30, 2007 9:15 AM
  • I think you must make your own control that's better !

     

    Thursday, August 30, 2007 10:09 AM
  • Like this maybe with trackbar2 min = 0 and max = 100 and maybe the value in the designer at 50 to start .

     

    Code Snippet

     

    Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick

    TrackBar1.Maximum = player.currentMedia.duration

    TrackBar1.Value = player.Ctlcontrols.currentPosition

    tracklabel.Text = TrackBar1.Maximum - TrackBar1.Value

    player.settings.volume = TrackBar2.Value

    End Sub

     

     

    Thursday, August 30, 2007 10:54 AM
  • thanks bdbodger

    I done it this way

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll

    wmp.settings.volume = TrackBar1.Value

    End Sub

    ..........................................................

     

    Private Sub T_Tick(ByVal sender As Object, _

    ByVal e As System.EventArgs) Handles T.Tick

    TrackBar1.Minimum = 0

    TrackBar1.Maximum = 100

    TrackBar1.Value = wmp.settings.volume

    end sub

     

    this seems to work nicely

    cheers

    Thursday, August 30, 2007 11:39 AM
  •  

    You wouldn't need a timer to set trackbar1 if it is for volume since it's value won't change a timer would be good for the position in the song since it changes as the song plays . The minimum and maximum can be set in the designer and trackbar1.value = wmp.settings.volume won't do anything anyway since it will still be the same as when you set it in the scroll event . All you would need to do a volume slider is the scroll event . I only added to the timer since it was easier than makeing a new sub and the timer was ticking at the default setting of  1/10 of a second or 100 miliseconds anyway . So that timer is pointless except maybe when the form loads then it will set the trackbar to 100 or what ever the default is .
    Thursday, August 30, 2007 12:41 PM
  • yeah, I got ya

    I just added it in there as this timer sets the play mode and other stuff

    thanks for the help

    cheers

    Thursday, August 30, 2007 1:06 PM