Andrei Yakugov
Andrei Yakugov

Reputation: 11

How to check mute or unmute while screen recording swift

I've used RPSystemBroadcastPickerView to record screen. (BroadcastExtension) I have to know mute/unmute status while screen recording. So please let me know how to check it.

Any help would be appreciated.

Upvotes: 0

Views: 274

Answers (1)

Ankur Lahiry
Ankur Lahiry

Reputation: 2315

In sampleBuffer, you have options for audio.

override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType)

where RPSampleBufferType has audio options.

@available(iOS 10.0, *)
public enum RPSampleBufferType : Int, @unchecked Sendable {

    
    case video = 1

    case audioApp = 2

    case audioMic = 3
}

You have to check both .audioApp & .audioMic.

Now print those values in processSampleBuffer methods. There should have level options as far as I can remember. try to extract the audio level from the metadata. If the audio level is under a threshold value then it is mute otherwise on. The threshold value is completely up to you.

Upvotes: 0

Related Questions