Mute audio tracks of live streams using AVPlayer

后端 未结 2 1024
野的像风
野的像风 2021-01-06 08:53

I am using AVPlayer to play live stream (m3U8 file). It plays perfectly using AVPlayer but I am not able to mute it.

I am using following code to mute the audio.

2条回答
  •  萌比男神i
    2021-01-06 09:13

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

提交回复
热议问题