Slide 1

Slide 1 text

EVERYTHING THEY DON’T TELL YOU ABOUT VIDEO IN THE BROWSER @philnash

Slide 2

Slide 2 text

Phil Nash @philnash http://philna.sh [email protected]

Slide 3

Slide 3 text

WEB PLATFORM @philnash

Slide 4

Slide 4 text

WEBRTC @philnash

Slide 5

Slide 5 text

PEER TO PEER @philnash

Slide 6

Slide 6 text

WebRTC Support ✅ ✅ ✅ ✅ ✅ @philnash

Slide 7

Slide 7 text

SORT OF... @philnash

Slide 8

Slide 8 text

THE ARCHITECTURE OF WEBRTC @philnash

Slide 9

Slide 9 text

WEBRTC TODAY @philnash

Slide 10

Slide 10 text

getUserMedia @philnash

Slide 11

Slide 11 text

SELECTING CAMERAS @philnash

Slide 12

Slide 12 text

THIS SHOULD BE EASY @philnash

Slide 13

Slide 13 text

Selecting cameras navigator.mediaDevices.getUserMedia({ video: true }) 01. 02. 03. @philnash

Slide 14

Slide 14 text

Selecting cameras navigator.mediaDevices.enumerateDevices() .then(devices => { // woo! }) 01. 02. 03. 04. @philnash

Slide 15

Slide 15 text

BUT... @philnash

Slide 16

Slide 16 text

MediaConstraints @philnash

Slide 17

Slide 17 text

Selecting cameras navigator.mediaDevices.getUserMedia({ video: ??? }) 01. 02. 03. @philnash

Slide 18

Slide 18 text

facingMode @philnash

Slide 19

Slide 19 text

Selecting cameras navigator.mediaDevices.getUserMedia({ video: { facingMode: ['user' | 'environment' | 'left' | 'right'] } }) 01. 02. 03. 04. 05. @philnash

Slide 20

Slide 20 text

deviceId @philnash

Slide 21

Slide 21 text

Selecting cameras navigator.mediaDevices.enumerateDevices().then(devices => { navigator.mediaDevices.getUserMedia({ video: { deviceId: devices[0].deviceId } }) }); 01. 02. 03. 04. 05. 06. 07. @philnash

Slide 22

Slide 22 text

BUT... @philnash

Slide 23

Slide 23 text

Selecting cameras navigator.mediaDevices.enumerateDevices().then(devices => { navigator.mediaDevices.getUserMedia({ video: { deviceId: { exact: devices[0].deviceId } } }) }); 01. 02. 03. 04. 05. 06. 07. @philnash

Slide 24

Slide 24 text

More constraints const constraints = { width: { min: 640, ideal: 1920, max: 1920 }, height: { min: 400, ideal: 1080 }, aspectRatio: 1.777777778, frameRate: { max: 30 }, facingMode: { exact: "user" } }; 01. 02. 03. 04. 05. 06. 07. @philnash

Slide 25

Slide 25 text

OverconstrainedError @philnash

Slide 26

Slide 26 text

SCREEN SHARING @philnash

Slide 27

Slide 27 text

Screen capture support ✅ @philnash

Slide 28

Slide 28 text

✨getDisplayMedia✨ @philnash

Slide 29

Slide 29 text

Screen capture navigator.getDisplayMedia() .then(stream => { // the stream is the display }); 01. 02. 03. 04. @philnash

Slide 30

Slide 30 text

PLUGINS @philnash

Slide 31

Slide 31 text

Screen capture - Chrome chrome.runtime.onMessageExternal.addListener((message, sender, sendResponse) =>; { const sources = message.sources; const tab = sender.tab; chrome.desktopCapture.chooseDesktopMedia(sources, tab, (streamId) => { if (!streamId) { sendResponse({ type: 'error', message: 'Failed to get stream ID' }); } else { sendResponse({ type: 'success', streamId: streamId }); } }); return true; }); 01. 02. 03. 04. 05. 06. 07. 08. 09. 10. 11. 12. 13. 14. 15. 16. 17. 18. @philnash

Slide 32

Slide 32 text

Screen capture - Chrome chrome.runtime.sendMessage(EXTENSION_ID, request, response => { if (response && response.type === 'success') { navigator.mediaDevices .getUserMedia({ video: { mandatory: { chromeMediaSource: 'desktop', chromeMediaSourceId: response.streamId } } }) } 01. 02. 03. 04. 05. 06. 07. 08. 09. 10. 11. 12. @philnash

Slide 33

Slide 33 text

NONSTANDARD BEHAVIOUR @philnash

Slide 34

Slide 34 text

Screen capture - Firefox navigator.mediaDevices.getUserMedia({ video: { mediaSource: 'screen' } }).then(returnedStream => { // use the stream }); 01. 02. 03. 04. 05. 06. 07. @philnash

Slide 35

Slide 35 text

Screen capture - Firefox function isFirefox() { var mediaSourceSupport = !!navigator.mediaDevices.getSupportedConstraints() .mediaSource; var matchData = navigator.userAgent.match(/Firefox\/(\d+)/); var firefoxVersion = 0; if (matchData && matchData[1]) { firefoxVersion = parseInt(matchData[1], 10); } return mediaSourceSupport && firefoxVersion >= 52; } 01. 02. 03. 04. 05. 06. 07. 08. 09. @philnash

Slide 36

Slide 36 text

STANDARDS COMING SOON @philnash

Slide 37

Slide 37 text

WEB AUDIO @philnash

Slide 38

Slide 38 text

Web audio const ctx = new AudioContext(); const oscillator = ctx.createOscillator(); oscillator.frequency = 400; oscillator.connect(ctx.destination); oscillator.start() 01. 02. 03. 04. 05. @philnash

Slide 39

Slide 39 text

Web audio const ctx = new AudioContext(); const analyser = ctx.createAnalyser(); 01. 02. @philnash

Slide 40

Slide 40 text

WEB PLATFORM++ @philnash

Slide 41

Slide 41 text

YOUR SKILLS++ @philnash

Slide 42

Slide 42 text

EVERYTHING THEY DON’T TELL YOU ABOUT VIDEO IN THE BROWSER @philnash

Slide 43

Slide 43 text

Thanks! @philnash http://philna.sh [email protected]