• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java volume control  RSS feed

 
greg ayal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im currently building a java music player and need some help in getting the volume control to work.
i want to be able to set the computers volume directly using an integer
ive created a slider and put the value into an integer
the part that im having trouble with is geting the volume to work
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please show us what you have do far.
 
greg ayal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks im so glad i found somebody to help

volume = Slider.getValue();
System.out.println(volume);

volume is a global variable from 0-100
i want to use those numbers to control the volume
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We need more details. What happens when you try that code? What sort of class is that slider?
 
Paweł Baczyński
Bartender
Posts: 2085
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably it's javafx.scene.control.Slider.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds likely. I thought it might be this.
 
greg ayal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help
what i want is to when the user changes the value on the slider , that same value changes the volume on the computer
the slider works the problem is i dont know how to control the volume of the computer with the value that the slider gives
ive attached a text file with all my code
https://drive.google.com/folderview?id=0B3Hpa-1d330mSXYwVXBPS1ZENFk&usp=sharing
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
greg ayal wrote:the problem is i dont know how to control the volume of the computer with the value that the slider gives


Okay. So do you know how to control the volume of the computer with a fixed value? Say, 75?

If you don't know that, then talking about sliders is just a diversion. You've seen how well that works so far -- people only want to talk about sliders.

 
Tony Docherty
Bartender
Posts: 3271
82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's an old thread on this very subject here: http://www.coderanch.com/t/492931/java/java/Adjusting-master-volume-Windows-XP which may or may not be of some use to you.
 
greg ayal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much.
this is what i have working now
 
greg ayal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It changes the volume depending on what the value of volume is
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does that actually work? If not, dave you managed it with one line? Once that works, you should then consider how to get the value from a slider.

I added code tags to your post. Always use the tags: doesn't it look better
 
greg ayal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you guys are the best
 
greg ayal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And yes it does work
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Complete with Slider? Well done
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!