0
我正在使用AVPlayer在iPhone中播放實時流式視頻。我想關閉播放器的音量(以編程方式)。我試過這個http://developer.apple.com/library/ios/#qa/qa1716/_index.html。但它不適用於我的情況。如何以編程方式在iPhone中靜音實時流式視頻
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[self myAssetURL] 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];
// assign player object to an instance variable
self.mPlayer = player;
// play the muted audio
[mPlayer play];
請爲此建議任何解決方案。 謝謝
到目前爲止你做了什麼?告訴我們一些代碼 – Lefteris
@Lefteris更新 –
我認爲你運氣不好。請[看到這個SO帖子](http://stackoverflow.com/a/12046195/312312) – Lefteris