0

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...

Genevios
  • 1,115
  • 1
  • 16
  • 29
  • Your syntax of method call is incorrect. I think you are a beginner and give some time to learn the basics, – Anoop Vaidya Dec 04 '13 at 10:20
  • @AnoopVaidya: Since he is asking a basic question, he currently _is_ learning the basics. Don't demotivate him. – DarkDust Dec 04 '13 at 10:23
  • @DarkDust: Yes I know, as we can see few others syntax and typo errors. Thats is why I commented. And I am sorry if he gets hurt by my comments. – Anoop Vaidya Dec 04 '13 at 10:26

1 Answers1

2

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.

DarkDust
  • 90,870
  • 19
  • 190
  • 224