iPhone client for network-computer: see and drive a remote Linux/Mac desktop over WebRTC, phone as trackpad and keyboard, desktop on a TV via AirPlay.

0 downloads

network-computer-ios/Sources/App/ExternalSceneDelegate.swift
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/network-computer-ios.git
HTTPS
https://gitstable.com/git/askrobots/network-computer-ios.git
SSH
ssh://git@gitstable.com:2222/askrobots/network-computer-ios.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Quellhorst First cut of the iPhone client cc1f67f 2 months ago History
ExternalSceneDelegate.swift · 1.4 KB · 37 lines
1import UIKit
2import Combine
3import WebRTC
4
5/// Drives a TV over USB-C/HDMI or AirPlay: the remote desktop fills the external
6/// screen at its native resolution while the phone stays a trackpad and keyboard.
7final class ExternalSceneDelegate: UIResponder, UIWindowSceneDelegate {
8 var window: UIWindow?
9 private var sub: AnyCancellable?
10
11 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
12 guard let ws = scene as? UIWindowScene else { return }
13 let w = UIWindow(windowScene: ws)
14 let vc = UIViewController()
15 vc.view.backgroundColor = .black
16 let video = RTCMTLVideoView(frame: vc.view.bounds)
17 video.videoContentMode = .scaleAspectFit
18 video.autoresizingMask = [.flexibleWidth, .flexibleHeight]
19 vc.view.addSubview(video)
20 w.rootViewController = vc
21 window = w
22 w.isHidden = false
23
24 sub = SessionStore.shared.$videoTrack.sink { [weak video] track in
25 guard let video else { return }
26 SessionStore.shared.externalRenderer = video
27 track?.add(video)
28 }
29 SessionStore.shared.externalDisplayConnected = true
30 }
31
32 func sceneDidDisconnect(_ scene: UIScene) {
33 SessionStore.shared.externalRenderer = nil
34 SessionStore.shared.externalDisplayConnected = false
35 sub = nil
36 }
37}