Horizontal ScrollBar/Seek Bar Code

Use this board to post your code snippets - tips and tricks
5 posts Page 1 of 1
Contributors
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Hi All
Here is a bit of code you can use with your MediaPlayers, and by adding a Horizontal ScrollBar Component you will be able to Drag the Slider to any position within the Track you are playing cooll;

The best way i found using this was to Change my FORM1 name to Player.vb

I am using a Horizontal Scrollbar ( Renamed to ScrollBar in the Properties )

Set the Maximum value to 100

And my MediaPlayer Component has been ( Renamed to PlayerControl in the Properties )

Player Load Code (Which was Form1 Load before i renamed it )
Code: Select all
PlayerControl.settings.autoStart = True
        PlayerControl.settings.volume = VolumeBar.Value
PlayBar Scroll Code ( Horizontal Scrollbar after being Renamed )
Code: Select all
 Try
            If (PlayerControl.currentMedia.duration <> 0) Then
                Dim NewPerc As Double = Convert.ToDouble(PlayBar.Value) / 100
                Dim DurationVar As Integer = Convert.ToInt32(PlayerControl.currentMedia.duration * 1000) ' milliseconds
                Dim NewPos As Integer = (DurationVar * NewPerc) / 1000


                PlayerControl.Ctlcontrols.currentPosition = NewPos
            Else
                PlayBar.Value = 0
            End If
        Catch ex As Exception
        End Try
And thats it

Easy Huh :)

Chris
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Hello hungryhounduk,

LOL you must have read my mind, I was just about to hunt through my code to find this because I needed it to test something out.

Good work Derren Brown ;) cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: Horizontal ScrollBar/Seek Bar Code
Nery
Derren Brown, great name indeed ;P
I like most of the English names, they sound so cool!

Anyway, Interesting to know that you like mountain biking, because I make mountain biking too, it's so exciting!


----- // -----

Now talking about your snippeT:

Hmm I was wondering how you made that bar in your MP3 Player before I saw this, It also helped me understanding how to add scrollbars, not just in MP3 Players but also in other applications

Greets,
Nery
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

lol yay u made this in no time i might make a ipod player simple one can i use this for it?
i will also credit ufor it since this is like a good thing
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Hi Codenstuff, Nery, Robby1998
Glad you can make use of it cooll;
It certainly does give a Mp3 Player or Media Application a bit more functionality

Respect

Chris
Image
5 posts Page 1 of 1
Return to “Quick Snips”