ソースを参照

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>

読み込み中…
キャンセル
保存