Tudor
Tudor

Reputation: 4164

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.

Upvotes: 6

Views: 9048

Answers (2)

Tudor
Tudor

Reputation: 4164

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

Upvotes: 13

r1d3h4rd
r1d3h4rd

Reputation: 141

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

Upvotes: -1

Related Questions