@@ -27,12 +27,25 @@ export class GleapScreenRecorder {
2727 }
2828
2929 getSupportedMimeType ( ) {
30- if ( MediaRecorder . isTypeSupported ( "video/mp4" ) ) {
31- return "video/mp4" ;
32- }
33- if ( MediaRecorder . isTypeSupported ( "video/webm;codecs=h264" ) ) {
34- return "video/webm;codecs=h264" ;
30+ // List of MIME types in order of preference
31+ const types = [
32+ "video/webm" ,
33+ "audio/webm" ,
34+ "video/webm;codecs=vp8" ,
35+ "video/webm;codecs=daala" ,
36+ "video/webm;codecs=h264" ,
37+ "audio/webm;codecs=opus" ,
38+ "video/mp4" ,
39+ ] ;
40+
41+ // Iterate through the list and return the first supported type
42+ for ( const type of types ) {
43+ if ( MediaRecorder . isTypeSupported ( type ) ) {
44+ return type ;
45+ }
3546 }
47+
48+ // If no types are supported, return a default or handle as needed
3649 return "video/webm" ;
3750 }
3851
@@ -64,7 +77,7 @@ export class GleapScreenRecorder {
6477 displaySurface : "monitor" ,
6578 } ,
6679 selfBrowserSurface : "include" ,
67- audio : true
80+ audio : true ,
6881 } )
6982 . then ( function ( displayStream ) {
7083 self . stream = displayStream ;
@@ -184,7 +197,7 @@ export class GleapScreenRecorder {
184197
185198 var recordedChunks = [ ] ;
186199 this . mediaRecorder = new MediaRecorder ( stream , {
187- mimeType : this . getSupportedMimeType ( )
200+ mimeType : this . getSupportedMimeType ( ) ,
188201 } ) ;
189202 this . isRecording = true ;
190203 this . recordTime = 0 ;
@@ -226,8 +239,10 @@ export class GleapScreenRecorder {
226239 type : this . getSupportedMimeType ( ) ,
227240 } ) ;
228241
229- this . file = new File ( [ completeBlob ] , `screen-recording.${ this . getSupportedMimeType ( ) === "video/mp4" ? 'mp4' : "webm" } ` , {
230- type : this . getSupportedMimeType ( ) ,
242+ const mimeType = this . getSupportedMimeType ( ) ;
243+ const extension = mimeType . includes ( "mp4" ) ? "mp4" : "webm" ;
244+ this . file = new File ( [ completeBlob ] , `screen-recording.${ extension } ` , {
245+ type : mimeType ,
231246 } ) ;
232247
233248 const previewVideoElement = document . querySelector (
0 commit comments