Skip to content

Conversation

@TobiasDuelli
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings October 6, 2025 15:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses audio recording issues in screen capture functionality by implementing a more robust audio handling system. The changes ensure audio tracks are properly captured and composed with video streams, fixing problems where audio was not being included in screen recordings.

  • Refactored audio handling to use separate streams for display and microphone capture
  • Added comprehensive MIME type support with audio codec preferences
  • Introduced proper error handling and resource cleanup for all media streams

Reviewed Changes

Copilot reviewed 2 out of 12 changed files in this pull request and generated 4 comments.

File Description
src/GleapScreenRecorder.js Major refactoring to fix audio capture by separating display and microphone streams, adding constants, improving error handling, and modernizing syntax
demo/main.js Configuration changes to commented out development URLs and updated API key

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +239 to 240
for (let i = 0; i < audioTracks.length; i++) {
const audioTrack = audioTracks[i];
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a for...of loop or forEach for better readability: for (const audioTrack of audioTracks) or audioTracks.forEach(audioTrack => { ... })

Suggested change
for (let i = 0; i < audioTracks.length; i++) {
const audioTrack = audioTracks[i];
for (const audioTrack of audioTracks) {

Copilot uses AI. Check for mistakes.
Comment on lines 289 to 291
this.mediaRecorder = new MediaRecorder(stream, {
mimeType: this.getSupportedMimeType(),
});
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MediaRecorder constructor could throw an exception if the MIME type is not supported. Consider wrapping in a try-catch block and providing a fallback MIME type or meaningful error message.

Suggested change
this.mediaRecorder = new MediaRecorder(stream, {
mimeType: this.getSupportedMimeType(),
});
try {
this.mediaRecorder = new MediaRecorder(stream, {
mimeType: this.getSupportedMimeType(),
});
} catch (e) {
// Fallback: try without mimeType or with a common one
try {
this.mediaRecorder = new MediaRecorder(stream);
} catch (fallbackError) {
// Optionally, try a very common mimeType
try {
this.mediaRecorder = new MediaRecorder(stream, {
mimeType: "video/webm",
});
} catch (finalError) {
// If all attempts fail, show a meaningful error and abort
alert("Screen recording is not supported in this browser or configuration.");
this.isRecording = false;
return;
}
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +355 to +357
this.audioAvailable = this.stream
? this.stream.getAudioTracks().length > 0
: this.audioAvailable;
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This ternary expression is unnecessarily complex. Consider simplifying to: this.audioAvailable = this.stream?.getAudioTracks().length > 0 ?? this.audioAvailable; or use a clearer if-else structure.

Suggested change
this.audioAvailable = this.stream
? this.stream.getAudioTracks().length > 0
: this.audioAvailable;
this.audioAvailable = this.stream?.getAudioTracks().length > 0 ?? this.audioAvailable;

Copilot uses AI. Check for mistakes.
};
try {
this.mediaRecorder.stop();
} catch (_) {}
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty catch blocks should be avoided or at least include a comment explaining why the error is being ignored. Consider logging the error for debugging purposes.

Suggested change
} catch (_) {}
} catch (error) {
// Log the error for debugging purposes; stopping may fail if already stopped or in an invalid state.
console.error("Error stopping mediaRecorder:", error);
}

Copilot uses AI. Check for mistakes.
@boehlerlukas boehlerlukas merged commit 05218e4 into master Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants