Professional Documents
Culture Documents
Quick access
Hi.
Mr. Monkeyboy
I'm looking for a way to make a trackbar on my form control music that plays through my
Joined May 2012
application. The trackbar would allow me to skip to different parts of the song.
Mr. Monkeyboy's …
Show activity
0 Also, how could I display the time left in the song and the total time that the song plays for in
4 5 17
Sign in labels?
to vote
Thx.
Bgeo99
Reply | Quote
Bgeo25 35 Points
Answers
1
Sign in
to vote
This seems to work pretty good. The system thread sleep is necessary to keep the WMP
control from running while the trackbar is being moved or else the track being played
attempts to perform all of the pause and plays for each increment of the track bar which is
ugly.
Option Strict On
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 1/12
25/10/2018 Trackbar Music Control
TrackBar1.Minimum = 0
Timer1.Interval = 100
End Sub
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 2/12
25/10/2018 Trackbar Music Control
Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of
DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you
post an image it clutters up the thread and mysteriously, over time, the link to the image will
somehow become "unstable" or something to that effect. :) I can only surmise that is due to
Global Warming of the threads.
Reply | Quote
Mr. Monkeyboy Nothing in particular 77,215 Points
All replies
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 3/12
25/10/2018 Trackbar Music Control
0
Sign in
to vote
Hi.
I'm looking for a way to make a trackbar on my form control music that plays through my
application. The trackbar would allow me to skip to different parts of the song.
Also, how could I display the time left in the song and the total time that the song plays
for in labels?
Thx.
Bgeo99
You make no mention of what control you are using to play the music.
If it is a windows media player control then you can use appropriate methods to display total
time and use a timer I suppose to get time left unless there is an event handler for that which I
am unaware of.
And in the track bar set its max value to whatever the current songs total time is I guess and
use appropriate math to convert the trackbars scale to move the location in the song, via call
to windows media player, to a new location I would imagine since that would be based on
time rather than decimal at that point.
If you are using Windows Media Player then you can look through this link at all the various
capabilities until you find the one that provides methods for getting information from the
windows media player for current songs duration and current songs "marker" location and
setting the "marker" location I believe is the term for the location in the song that you want it
to move to.
Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of
DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you
post an image it clutters up the thread and mysteriously, over time, the link to the image will
somehow become "unstable" or something to that effect. :) I can only surmise that is due to
Global Warming of the threads.
Reply | Quote
Mr. Monkeyboy Nothing in particular 77,215 Points
0
Sign in
to vote
My bad. If you're using WMP control then you can use double to set the current position
although in the timer I am getting rather than setting the current position.
Option Strict On
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 4/12
25/10/2018 Trackbar Music Control
Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of
DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you
post an image it clutters up the thread and mysteriously, over time, the link to the image will
somehow become "unstable" or something to that effect. :) I can only surmise that is due to
Global Warming of the threads.
Reply | Quote
Mr. Monkeyboy Nothing in particular 77,215 Points
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 5/12
25/10/2018 Trackbar Music Control
1
Sign in
to vote
This seems to work pretty good. The system thread sleep is necessary to keep the WMP
control from running while the trackbar is being moved or else the track being played
attempts to perform all of the pause and plays for each increment of the track bar which is
ugly.
Option Strict On
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 6/12
25/10/2018 Trackbar Music Control
Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of
DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you
post an image it clutters up the thread and mysteriously, over time, the link to the image will
somehow become "unstable" or something to that effect. :) I can only surmise that is due to
Global Warming of the threads.
Reply | Quote
Mr. Monkeyboy Nothing in particular 77,215 Points
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 7/12
25/10/2018 Trackbar Music Control
0
Sign in
to vote
I used the code from above, but it still isn't working.. Maybe its because the trackbar
increment is incorrect? What should it be set to? I used the code below and the build of the
application was successful, but the media still won't play. Also, the trackbar freezes when I
press the button to play (Button1)..
Option Strict On
Public Class Form1
Bgeo99
Reply | Quote
Bgeo25 35 Points
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 8/12
25/10/2018 Trackbar Music Control
0
Sign in
to vote
I'm using Visual Studio 2012 and used the Windows Media Player control that is in my
toolbox.
Perhaps you should try using clean, then rebuild instead of build.
Half the time I build an app with the WMP in it the form disappears from the designer and for
that window a blank white page is displayed with an error. Then I have to close and reopen
the project for some reason.
Although I just noticed I have a reference to WMP.Dll set in browse for references.
Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of
DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you
post an image it clutters up the thread and mysteriously, over time, the link to the image will
somehow become "unstable" or something to that effect. :) I can only surmise that is due to
Global Warming of the threads.
Reply | Quote
Mr. Monkeyboy Nothing in particular 77,215 Points
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 9/12
25/10/2018 Trackbar Music Control
0
Sign in
to vote
Okay. I tried a different song and it worked. Turns out something was wrong with the song I
picked -__-
Anyway, when I play a video I see that the player is shaded green over 75% of the box and it's
covering the video. Is it because the plugin is corrupt?
Bgeo99
Reply | Quote
Bgeo25 35 Points
1
Sign in
to vote
Okay. I tried a different song and it worked. Turns out something was wrong with the
song I picked -__-
Anyway, when I play a video I see that the player is shaded green over 75% of the box
and it's covering the video. Is it because the plugin is corrupt?
Bgeo99
I would have no idea since I have not had that issue before.
Also this is how you would do the same thing without dropping the WMP control on your
Form. So you're just playing audio of whatever you want to listen to, even videos, but there is
a requirement to add more controls to the form since the WMP isn't displayed and you can't
access its controls.
Although there may be a parameter to make the WMP display for all I know and even set its
location on the form.
Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of
DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you
post an image it clutters up the thread and mysteriously, over time, the link to the image will
somehow become "unstable" or something to that effect. :) I can only surmise that is due to
Global Warming of the threads.
Reply | Quote
Mr. Monkeyboy Nothing in particular 77,215 Points
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 11/12
25/10/2018 Trackbar Music Control
0
Sign in
to vote
Reply | Quote
Fusionultralight 0 Points
United States © 2018 Microsoft Terms of Use Trademarks Privacy Statement Site Feedback
(English)
https://social.msdn.microsoft.com/Forums/vstudio/en-US/34ac95f5-4cad-4b11-937a-de2ee5896c04/trackbar-music-control?forum=vbgeneral 12/12