Skip to content

Commit

Permalink
fix refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ikuosaito1989 committed May 22, 2020
1 parent 5170731 commit 12ba98e
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
input.oninput = (event) => {
this.zoom.value = event.target.value
this.track.applyConstraints({
advanced : [{focusMode: "manual", zoom: event.target.value}]
advanced : [{ zoom: event.target.value }]
});
}
}
Expand Down Expand Up @@ -245,30 +245,29 @@
},
async _playVideo () {
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
this._stopVideo()

if(this.video.srcObject){
this.video.srcObject.getVideoTracks().forEach(video => {
video.stop();
});
}

try {
const stream = await navigator.mediaDevices.getUserMedia(this.constraints)
this.video.srcObject = stream
// @note getVideoTracksを利用する場合起動するまで時間がかかるので少し待つ必要がある
await new Promise(r => setTimeout(r, 500))
this.onChangeFocusMode()
this.initZoom()
this.initWhiteBalanceMode()
this.supportStatus = `capabilities: ${JSON.stringify(this.capabilities)}
settings: ${JSON.stringify(this.track.getSettings())}`
this.video.srcObject = await navigator.mediaDevices.getUserMedia(this.constraints)
} catch(e) {
alert(e.name)
}
alert(`${e.name} : ${e.message}`)
}

// @note getVideoTracksを利用する場合起動するまで時間がかかるので少し待つ必要がある
await new Promise(r => setTimeout(r, 500))
this.onChangeFocusMode()
this.initZoom()
this.initWhiteBalanceMode()
this.supportStatus = `capabilities: ${JSON.stringify(this.capabilities)}
settings: ${JSON.stringify(this.track.getSettings())}`
}

},
_stopVideo () {
if(this.video.srcObject){
this.video.srcObject.getVideoTracks().forEach(video => {
video.stop();
});
}
},
}
});
</script>
Expand Down

0 comments on commit 12ba98e

Please sign in to comment.