This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ViewController: RPBroadcastActivityViewControllerDelegate { | |
func broadcastActivityViewController(_ broadcastActivityViewController: RPBroadcastActivityViewController, didFinishWith broadcastController: RPBroadcastController?, error: Error?) { | |
// Step 1 | |
guard error == nil else { | |
print("Broadcast Activity Controller is not available.") | |
return | |
} | |
// Step 2 | |
broadcastActivityViewController.dismiss(animated: true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func runBroadcast() { | |
// Step 1 | |
RPBroadcastActivityViewController.load { broadcastAVC, error in | |
// Step 2 | |
guard error == nil else { | |
print("Cannot load Broadcast Activity View Controller.") | |
return | |
} | |
// Step 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReplayKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var mainView: UIView! | |
let controller = RPBroadcastController() | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func runRecording() { | |
guard recorder.isAvailable else { | |
print("Recording is not available at this time.") | |
return | |
} | |
recorder.startRecording{ [unowned self] (error) in | |
guard error == nil else { | |
print("There was an error starting the recording.") | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReplayKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var mainView: UIView! | |
let recorder = RPScreenRecorder.shared() | |
private var isRecording = false | |
override func viewDidLoad() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check tool | |
if test "x$(which mobiledevice)" = "x"; then | |
echo "install mobiledevice" | |
brew install mobiledevice | |
fi | |
# query mobile list then pick up the first one | |
MOBILE_UUID=$( bash <<EOF | |
/usr/local/bin/mobiledevice list_devices -n 1 | |
EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func updateFeatures(for node: SCNNode, using anchor: ARFaceAnchor) { | |
for (feature, indices) in zip(features, featureIndices) { | |
let child = node.childNode(withName: feature, recursively: false) as? EmojiNode | |
let vertices = indices.map { anchor.geometry.vertices[$0] } | |
child?.updatePosition(for: vertices) | |
switch feature { | |
case "leftEye": | |
let scaleX = child?.scale.x ?? 1.0 | |
let eyeBlinkValue = anchor.blendShapes[.eyeBlinkLeft]?.floatValue ?? 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmojiNode: SCNNode { | |
var options: [String] | |
var index = 0 | |
init(with options: [String], width: CGFloat = 0.06, height: CGFloat = 0.06) { | |
self.options = options | |
super.init() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func updateFeatures(for node: SCNNode, using anchor: ARFaceAnchor) { | |
for (feature, indices) in zip(features, featureIndices) { | |
let child = node.childNode(withName: feature, recursively: false) as? EmojiNode | |
let vertices = indices.map { anchor.geometry.vertices[$0] } | |
child?.updatePosition(for: vertices) | |
switch feature { | |
case "leftEye": | |
let scaleX = child?.scale.x ?? 1.0 | |
let eyeBlinkValue = anchor.blendShapes[.eyeBlinkLeft]?.floatValue ?? 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? { | |
guard let faceAnchor = anchor as? ARFaceAnchor, | |
let device = sceneView.device else { return nil } | |
let faceGeometry = ARSCNFaceGeometry(device: device) | |
let node = SCNNode(geometry: faceGeometry) | |
node.geometry?.firstMaterial?.fillMode = .lines | |
node.geometry?.firstMaterial?.transparency = 0.0 // hide mask line | |
let noseNode = EmojiNode(with: noseOptions) | |
noseNode.name = "nose" |