Mute audio tracks of live streams using AVPlayer

北战南征 提交于 2019-11-30 22:16:30

Your assumption is correct. You cannot mute a player that is playing an HTTP Live Stream. I have filed a RADAR on this.

In my app we control the streams, so we produced a stream with no audio, and an identical stream with audio, and switch between the 2 to turn on and off the sound. It's the best you can do.

The AVAudioMix solution doesn't work on live streams. I tried. Look at the note on the bottom that says it only works on file based assets: http://developer.apple.com/library/ios/#qa/qa1716/_index.html

It looks like Mac Developers get a mute property on their AVPlayer, but iOS doesn't have it yet.

For now, you will have to work around the problem in your streams, if you can.

Alexander Kostiev

As a workaround you may use the MPVolumeView class to adjust the volume of any video. This will allow the user to mute the video if they desire. But unlikely you can't customize this slider's appearance without using the undocumented API.

MPVolumeView *volumeView = [[[MPVolumeView alloc] initWithFrame: CGRectMake(10, 37, 260, 20)] autorelease];

UIAlertView *volumeAlert = [[UIAlertView alloc] initWithTitle:@"Volume" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

[volumeView sizeToFit];
[volumeAlert addSubview:volumeView];
[volumeAlert show];
[volumeAlert release];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!