Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions GoLive/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -104,6 +104,7 @@
<outlet property="broadcastButton" destination="tL4-2S-1Xx" id="LTc-Ll-GBH"/>
<outlet property="colorSelector" destination="hIQ-gJ-1O9" id="RW6-UB-1cP"/>
<outlet property="colorView" destination="FRj-uP-fsm" id="vxJ-eg-lp3"/>
<outlet property="micLabel" destination="T7y-DL-IMw" id="h9f-cQ-eth"/>
<outlet property="micSwitch" destination="Xbd-Ej-U93" id="F8o-O8-gN9"/>
<outlet property="statusLabel" destination="G6P-o7-xf2" id="OJR-G4-hQD"/>
</connections>
Expand Down
41 changes: 23 additions & 18 deletions GoLive/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ViewController: UIViewController, RPBroadcastActivityViewControllerDelegat
@IBOutlet var micSwitch: UISwitch!
@IBOutlet var micLabel: UILabel!

let controller = RPBroadcastController()
var controller: RPBroadcastController?
let recorder = RPScreenRecorder.shared()

override func viewDidLoad() {
Expand All @@ -29,10 +29,9 @@ class ViewController: UIViewController, RPBroadcastActivityViewControllerDelegat

@IBAction func didPressBroadcastButton() {
// Called when broadcast button is tapped. Runs functions to start or stop broadcast.
if controller.isBroadcasting {
if let isBroadcasting = controller?.isBroadcasting, isBroadcasting {
stopBroadcast()
}
else {
} else {
startBroadcast()
}
}
Expand Down Expand Up @@ -64,6 +63,9 @@ class ViewController: UIViewController, RPBroadcastActivityViewControllerDelegat
print("Broadcast Activity Controller is not available.")
return
}
if let bcController = broadcastController {
self.controller = bcController
}

//2
broadcastActivityViewController.dismiss(animated: true) {
Expand All @@ -82,7 +84,7 @@ class ViewController: UIViewController, RPBroadcastActivityViewControllerDelegat

func stopBroadcast() {

controller.finishBroadcast { error in
controller?.finishBroadcast { error in
if error == nil {
print("Broadcast ended")
self.broadcastEnded()
Expand All @@ -92,21 +94,25 @@ class ViewController: UIViewController, RPBroadcastActivityViewControllerDelegat


func broadcastStarted() {
// Called to update the UI when a broadcast starts.
broadcastButton.setTitle("Stop Broadcast", for: .normal)
statusLabel.text = "You are live!" // Any app that does not notify the user that they are live will be rejected in app review.
statusLabel.textColor = UIColor.red
micSwitch.isHidden = false
micLabel.isHidden = false
DispatchQueue.main.sync {
// Called to update the UI when a broadcast starts.
broadcastButton.setTitle("Stop Broadcast", for: .normal)
statusLabel.text = "You are live!" // Any app that does not notify the user that they are live will be rejected in app review.
statusLabel.textColor = UIColor.red
micSwitch.isHidden = false
micLabel.isHidden = false
}
}

func broadcastEnded() {
// Called to update the UI when a broadcast ends.
broadcastButton.setTitle("Start Broadcast", for: .normal)
statusLabel.text = "You are not live"
statusLabel.textColor = UIColor.black
micSwitch.isHidden = true
micLabel.isHidden = true
DispatchQueue.main.sync {
// Called to update the UI when a broadcast ends.
broadcastButton.setTitle("Start Broadcast", for: .normal)
statusLabel.text = "You are not live"
statusLabel.textColor = UIColor.black
micSwitch.isHidden = true
micLabel.isHidden = true
}
}


Expand Down Expand Up @@ -153,4 +159,3 @@ class ViewController: UIViewController, RPBroadcastActivityViewControllerDelegat


}