Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After speaking to an Apple technician it turns out that it's not possible to control or mute the audio using <code>MPMoviePlayerController</code>.</p> <p>Instead you have to create your own controller using AVFoundations <code>AVPlayer</code> class.</p> <p>Once you're using that it's a matter of creating a custom audio mix and setting the volume level. It actually works very well.</p> <p>Sample code:</p> <pre><code> AVURLAsset * asset = [AVURLAsset URLAssetWithURL:[self localMovieURL] options:nil]; NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio]; // Mute all the audio tracks NSMutableArray * allAudioParams = [NSMutableArray array]; for (AVAssetTrack *track in audioTracks) { AVMutableAudioMixInputParameters *audioInputParams =[AVMutableAudioMixInputParameters audioMixInputParameters]; [audioInputParams setVolume:0.0 atTime:kCMTimeZero ]; [audioInputParams setTrackID:[track trackID]]; [allAudioParams addObject:audioInputParams]; } AVMutableAudioMix * audioZeroMix = [AVMutableAudioMix audioMix]; [audioZeroMix setInputParameters:allAudioParams]; // Create a player item AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset]; [playerItem setAudioMix:audioZeroMix]; // Mute the player item // Create a new Player, and set the player to use the player item // with the muted audio mix AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem]; self.mPlayer = player; [mPlayer play]; </code></pre> <p>I've written an <code>MPMoviePlayerController</code> replacement class that adds support for volume level. I will upload the to github shortly and add the link in this post.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload