Can MPMoviePlayerController have software volume control?

I have this MPMovePlayerController and a custom slider (which is not exactly a slider, but has the same purpose). Given that my β€œslider” can return any float value that I need, how can I change the volume of the movie being played?

While I was trying to hack MPVolumeView, to programmatically set the value without success.

+6
source share
2 answers

iOS 3.0 - 7.0

Turns out that

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

works for any sound in the application, even MPMoviePlayerController if it uses the main audio session. Oh, this only works on the device, not on the simulator. More information here: https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller?language=objc


Refresh

Volume is not recommended in iOS 7.0.

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

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

It will change the volume of the device, not the media player, so that any other audio or video streams also affect.

-1
source

Source: https://habr.com/ru/post/885680/


All Articles