【问题标题】:How to programmatically mute live streaming video in iPhone如何以编程方式将 iPhone 中的实时流媒体视频静音
【发布时间】:2013-04-03 09:55:38
【问题描述】:

我正在使用 AVPlayer 在 iPhone 中播放实时流媒体视频。我想关闭播放器的音量(以编程方式)。我试过这个http://developer.apple.com/library/ios/#qa/qa1716/_index.html。但它不适用于我的情况。

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];

请为此提出任何解决方案。 谢谢

【问题讨论】:

  • 到目前为止你做了什么?给我们看一些代码
  • 我觉得你运气不好。请see this SO post
  • 我相信没有选项可以在直播中将视频静音。到目前为止我知道。您可以使用 MPMoviePlayerController 中的音量控件来执行此功能。

标签: ios objective-c volume avplayer


【解决方案1】:

您可以使用 MPVolumeView 类,在 [此处] 可用。它有一个音量控制滑块,也适用于 HTTP Live Streams。(http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPVolumeView_Class/Reference/Reference.html)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-25
    • 1970-01-01
    • 2014-04-01
    • 2012-01-03
    • 2010-10-20
    • 1970-01-01
    • 2014-02-09
    相关资源
    最近更新 更多