PVVolumeBar is a simple NSView
subclass that emulates the Volume Bar you'd normally see on VLC when it's in full screen mode.
Here's the comparison between the VLC's volume bar and what you can do with PVVolumeBar
PVVolumeBar
uses ARC and requires OS X 10.7+.
- Add both .h and .m files of
PVVolumeBar
to your project. - Import
PVVolumeBar.h
to wherever you want to use it just by#import "PVVolumeBar.h"
- Set the
PVVolumeBar
class to yourNSView
in Interface Builder or by code - You're ready to kickass!
[_volumeBar setHasBorder:YES]; //Show the border
[_volumeBar setHasBorder:NO]; //Hide the border
//Change the border color to any color you want
[_volumeBar setBorderColor:[NSColor cyanColor]];
//Change the border width
[_volumeBar setBorderWidth:5.0];
//Change the volume bar color to any color you want
[_volumeBar setBarColor:[NSColor redColor]];
//Change the space between the volume bar and the border
[_volumeBar setSpaceBetweenBorderAndBar:10.0];
If you look closely to the VLC volume bar, you can notice that there are 2 small squares, in each side of the volume bar, in the 100% volume level. In PVVolumeBar
, that's called Lateral Volume Pads
. Here's an example image of that:
![comparison](screenshots/VLC volume pads.png)
You can easily display the volume pads using the following code:
//First you need to say to your PVVolumeBar that you want to show the Lateral Volume Pads
[_volumeBar setShowsLateralVolumePads:YES];
//And then, you need to say the volume you want to use so that the Lateral Volume Pads are displayed there.
//For example, if your minimum volume is 0.0, maximum volume is 1.0 and you set 0.5 as the volume for the Lateral Volume Pads
//the Lateral Volume Pads will be displayed right in the center of the Volume Bar
[_volumeBar setVolumeForLateralVolumePads:0.5];
There are several ways of changing the current volume:
//Change the current volume right away
[_volumeBar setCurrentVolume:1.0];
//Change the current volume using a smooth animation
[_volumeBar setCurrentVolume:1.0 animated:YES];
//Increase or decrease the current volume
[_volumeBar increaseCurrentVolumeBy:0.1 animated:YES];
[_volumeBar decreaseCurrentVolumeBy:0.1];
Here's how it looks like when changing volume using animations:
This includes an example project that you can use to play around with PVVolumeBar
and see how it feels and works.
If you're developing an app using PVVolumeBar, tell me something and I'll put a link here.
PVVolumeBar was created by Pedro Vieira.
pedrovieira.me
@w1tch_
[email protected]
Check "LICENSE" to know more (MIT).