Skip to content

Commit

Permalink
Add sound with screenrecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
QVDev committed Sep 19, 2019
1 parent 2292d20 commit 75b2cc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<meta charset="utf-8">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].7/js/GunRecorder.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].7/js/GunStreamer.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].7/js/GunViewer.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].7/js/mediabuffer.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].8/js/GunRecorder.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].8/js/GunStreamer.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].8/js/GunViewer.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].8/js/mediabuffer.js"></script>
</head>

<body>
Expand All @@ -22,7 +22,7 @@
<br>
Viewer<br>
<video id="remote" width="20%" autoplay muted></video>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].7/js/integration.js"></script>
<script src="https://cdn.jsdelivr.net/gh/QVDev/[email protected].8/js/integration.js"></script>
</body>

</html>
10 changes: 7 additions & 3 deletions js/GunRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ class GunRecorder {
}
var gunRecorder = this;
if (navigator.mediaDevices.getDisplayMedia && navigator.mediaDevices.getDisplayMedia) {
navigator.mediaDevices.getDisplayMedia(this.cameraOptions).then(function (stream) {
gunRecorder.video.srcObject = stream;
gunRecorder.video.play();
navigator.mediaDevices.getDisplayMedia(this.cameraOptions).then(function (desktopStream) {
navigator.mediaDevices.getUserMedia({ video: false, audio: true }).then(function (voiceStream) {
let tracks = [desktopStream.getVideoTracks()[0], voiceStream.getAudioTracks()[0]]
var stream = new MediaStream(tracks);
gunRecorder.video.srcObject = stream;
gunRecorder.video.play();
});
});
this.setRecordingState(recordSate.STOPPED);
} else {
Expand Down

0 comments on commit 75b2cc4

Please sign in to comment.