MCPcopy Create free account
hub / github.com/EmulatorJS/EmulatorJS / collectScreenRecordingMediaTracks

Method collectScreenRecordingMediaTracks

data/src/emulator.js:6031–6071  ·  view source on GitHub ↗
(canvasEl, fps)

Source from the content-addressed store, hash-verified

6029 }
6030
6031 collectScreenRecordingMediaTracks(canvasEl, fps) {
6032 let videoTrack = null;
6033 const videoTracks = canvasEl.captureStream(fps).getVideoTracks();
6034 if (videoTracks.length !== 0) {
6035 videoTrack = videoTracks[0];
6036 } else {
6037 console.error("Unable to capture video stream");
6038 return null;
6039 }
6040
6041 let audioTrack = null;
6042 if (this.Module.AL && this.Module.AL.currentCtx && this.Module.AL.currentCtx.audioCtx) {
6043 const alContext = this.Module.AL.currentCtx;
6044 const audioContext = alContext.audioCtx;
6045
6046 const gainNodes = [];
6047 for (let sourceIdx in alContext.sources) {
6048 gainNodes.push(alContext.sources[sourceIdx].gain);
6049 }
6050
6051 const merger = audioContext.createChannelMerger(gainNodes.length);
6052 gainNodes.forEach(node => node.connect(merger));
6053
6054 const destination = audioContext.createMediaStreamDestination();
6055 merger.connect(destination);
6056
6057 const audioTracks = destination.stream.getAudioTracks();
6058 if (audioTracks.length !== 0) {
6059 audioTrack = audioTracks[0];
6060 }
6061 }
6062
6063 const stream = new MediaStream();
6064 if (videoTrack && videoTrack.readyState === "live") {
6065 stream.addTrack(videoTrack);
6066 }
6067 if (audioTrack && audioTrack.readyState === "live") {
6068 stream.addTrack(audioTrack);
6069 }
6070 return stream;
6071 }
6072
6073 screenRecord() {
6074 const captureFps = this.getSettingValue("screenRecordingFPS") || this.capture.video.fps;

Callers 1

screenRecordMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected