Question

I write application for Mac OS. So it will be audio player. Now i try to make volume slider from AVPLayer but i have some problem. So i tried this code:

in h file:

IBOutlet NSLider *volumeSlider;
IBOutlet NSButton *button;
AVPlayer *myplayer;

-(IBAction)changeslider;

in m file:

[myplayer.volume=volumeSlider.value]

So i have error Assigning to 'float' from incompatible type 'id'. So what i doing wrong? I know hot to make volume slider in IOS from MPMVolumeView but Mac OS used ONLY AVPlayer or AVAudioPlayer. Thanks for answers.

So i have some idea with + or - volume from buttons.

NSString *change
change = @"%@", +1;
iPodplayer.volume=change;

But i also have error with float...

Was it helpful?

Solution

You need to do:

myplayer.volume = volumeSlider.floatValue;

The volume property on AVPlayer wants a float, yet in the first example you tried to assign it a value of type id, and in the second a value of type NSString. BTW, the expression change = @"%@", 1; is not doing what you think it does: it assigns a string %@ (really the percent sign and an "at" sign), then evaluates the number 1 and just ignores it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top