June 2024
Beginner to intermediate
268 pages
6h 26m
English
Having made that detour to improve the WebRTC code with adapter.js, let’s get back to work on the goal of applying video filters remotely. Take the anonymous click-event handler you wrote earlier and rewrite it as a handleSelfVideo() callback. Start by immediately exiting the callback function when the peer connection state is anything other than connected:
| | document.querySelector('#self') |
| | .addEventListener('click', handleSelfVideo); |
| | |
| | function handleSelfVideo(event) { |
| » | if ($peer.connection.connectionState !== 'connected') return; |
| | const filter = `filter-${$self.filters.cycleFilter()}`; |
| | event.target.className = filter; |
| | } |
Now the click event won’t ...
Read now
Unlock full access