Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 当我们使用AVPlayer播放时,如何使音频静音_Iphone_Ios_Objective C_Avaudioplayer_Avplayer - Fatal编程技术网

Iphone 当我们使用AVPlayer播放时,如何使音频静音

Iphone 当我们使用AVPlayer播放时,如何使音频静音,iphone,ios,objective-c,avaudioplayer,avplayer,Iphone,Ios,Objective C,Avaudioplayer,Avplayer,我正在使用下面的代码播放音频文件 -(IBAction)hearAudioMessage:(id)sender { ChatObject * obj = [chatArray objectAtIndex:rowIndexInt]; NSString *str=[NSString stringWithFormat:@"http://www.myserver.com/files/%@",obj.voiceFileString]; self.palyer=[[AVPlayer all

我正在使用下面的代码播放音频文件

    -(IBAction)hearAudioMessage:(id)sender
{
ChatObject * obj = [chatArray objectAtIndex:rowIndexInt];
 NSString *str=[NSString stringWithFormat:@"http://www.myserver.com/files/%@",obj.voiceFileString];
    self.palyer=[[AVPlayer alloc] initWithURL:[NSURL URLWithString:str]];
    [self.palyer play];
}
现在,我想在播放时将音频静音

我使用了下面的代码,但它对我无效

NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];

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 *audioMix = [AVMutableAudioMix audioMix];
[audioMix setInputParameters:allAudioParams];

AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
[playerItem setAudioMix:audioMix];
请提出其他选择?或者,当我们使用AVPlayer播放时,如何使音频静音


提前感谢

使用下一行将音频静音


[玩家暂停]

“没有为我工作”是什么意思?声音会播放吗?另外,你说你播放了一个音频文件,然后你说你想在播放时静音?是的,声音正在播放。。我想将音频@zoul静音