开发者

Can MPMoviePlayerController have volume programmatically adjusted?

I have this MPMovePlayerController and a custom slider (which is not quite a slider, but it has the same purpose). Considering that my "slider" can return any float value I need, how can I change the volume of the played movie?

So far I'v tried hacking M开发者_运维技巧PVolumeView to programmatically set a value, w/o success.


iOS 3.0 - 7.0

Turns out that

[[MPMusicPlayerController applicationMusicPlayer] setVolume:<insert float here>];

works for any sound in the app, even the MPMoviePlayerController, if it's using the main Audio Session. O, it works only on the device, not the simulator. More info here: https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller?language=objc


Update

Volume is deprecated in iOS 7.0.

"To provide UI for adjusting system playback volume, use the MPVolumeView class, which provides media playback controls that iOS users expect and whose appearance you can customize." Deprecated MPMusicPlayerController Volume Method


[[MPMusicPlayerController applicationMusicPlayer] setVolume:<insert float here>];

Will change the device's volume, not the media player's so any other audio or video streams are also affected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜