소스 검색

Basics for screen sharing

master
Roderic Day 4 년 전
부모
커밋
a203c57a3b
2개의 변경된 파일12개의 추가작업 그리고 5개의 파일을 삭제
  1. +10
    -5
      apps/screen.js
  2. +2
    -0
      pico.html

+ 10
- 5
apps/screen.js 파일 보기

@@ -12,20 +12,25 @@ const ScreenShare = {
isOn: false,
start() {
const screen = document.querySelector('video.screen')
navigator.mediaDevices.getDisplayMedia()
if(screen) {
navigator.mediaDevices.getDisplayMedia()
.then(s => {screen.srcObject = s})
.catch(e => console.error(e))
}
},
toggle() {
ScreenShare.isOn = !ScreenShare.isOn
// ScreenShare.start()
if(ScreenShare.isOn) {
// setTimeout(ScreenShare.start, 100)
}
},
view() {
const style = {
width: '80%',
height: '80%',
overflow: 'scroll',
}
return m('video.screen[playsinline][autoplay]', {style})
return ScreenShare.isOn && m('div', {style},
m('video.screen[playsinline][autoplay]'),
)
},
}
addEventListener('load', () => {

+ 2
- 0
pico.html 파일 보기

@@ -40,6 +40,8 @@ header {
}
main {
overflow: hidden;
display: grid;
grid-auto-flow: column;
}
</style>
<body>PicoChat requires JS</body>

Loading…
취소
저장