Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 MPVolumeView to programmatically set a value, w/o success.

like image 762
Tudor Avatar asked Apr 11 '11 20:04

Tudor


1 Answers

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

like image 191
Tudor Avatar answered Nov 13 '22 08:11

Tudor