Swift Broadcast Replaykit Stop Recording

1.5k views Asked by At

I have this code for running the BroadCast now I need one Button in App to stop broadcast without going to Notification Centre is that possible.

override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        UIScreen.main.addObserver(self, forKeyPath: "captured", options: .new, context: nil)

    }


func addRPkitVw() {



        let broadcastPickerView = RPSystemBroadcastPickerView(frame: CGRect(x: (holderVw.frame.width / 2) - 19, y: 0, width: 38, height: 38))
        holderVw.addSubview(broadcastPickerView)
        broadcastPickerView.backgroundColor = .clear
        broadcastPickerView.showsMicrophoneButton = true
    }
2

There are 2 answers

0
Ken Laam On

I'm facing same issue, but have you tried with finishBroadcastWithError in RPBroadcastSampleHandler. It's temporary solution, cus there is error popup

3
Ankita Pundir On

You have to pass a message to our Extension Whenever you need to stop the recording. Now in your Upload Broadcast Extension when you get the message just call the finishBroadcastWithError function and pass your own error type. Example:- Recording successfully stoped etc.

something Like this will display to user after stream stops