[英]How to make Volume Slider for mac application
I write application for Mac OS. 我为Mac OS编写应用程序。 So it will be audio player.
所以这将是音频播放器。 Now i try to make volume slider from AVPLayer but i have some problem.
现在我尝试从AVPLayer制作音量滑块,但我有一些问题。 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'. 所以我有错误从不兼容的类型'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.
我知道从MPMVolumeView在IOS中制作音量滑块很热,但Mac OS仅使用AVPlayer或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... 但我也有浮动错误...
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
. AVPlayer
上的volume
属性需要一个float,但在第一个例子中,你试图为它赋值id
类型,在第二个例子中为NSString
类型的值。 BTW, the expression change = @"%@", 1;
顺便说一句,表达式
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. 没有做你认为它做的事情:它分配一个字符串
%@
(实际上是百分号和“at”符号),然后评估数字1并忽略它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.