9/17/2008

QTKit - Change Volume via IB Slider

To change the volume of a movie with a slider from the interface:

//MyControl.h
#import Cocoa/Cocoa.h
#import QTKit/QTKit.h

@interface MyControler : NSObject {
IBOutlet QTMovieView *MyMovieView
IBOutlet NSSlider *MyVolumeSlider
}
-(IBAction) changeVolume:(id)sender;

@end


//MyControl.m
#import MyControl.h
#import QTKit/QTKit.h

implementation MyControl

-(IBAction) changeVolume:(id)sender
{
float volumeValue = [sender floatValue];
[[MyMovieView movie] setVolume:volumeValue];
}



The Slider in the interface must be set to MaxValue 1 and MinValue 0, while the volumeValue is a float value.


No comments: