File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -411,19 +411,17 @@ function main(): void
411411 saveBtn . addEventListener ( "click" , onSave ) ;
412412
413413 const loadExampleBtn = document . getElementById ( "loadExampleButton" ) ! ;
414- loadExampleBtn . addEventListener ( "click" , ( ) => {
414+ loadExampleBtn . addEventListener ( "click" , ( _event ) => {
415415 const exampleFileName = "assets/bbb_sunflower_1080p_60fps_normal.mp4.torrent" ;
416416
417- const xreq = new XMLHttpRequest ( ) ;
418- xreq . onreadystatechange = ( ) => {
419- if ( ( xreq . readyState !== XMLHttpRequest . DONE ) || ( xreq . status !== 200 ) )
420- return ;
417+ void fetch ( exampleFileName , { method : "GET" } )
418+ . then ( async ( response ) => {
419+ if ( ! response . ok )
420+ return ;
421421
422- loadData ( exampleFileName , xreq . response ) ;
423- } ;
424- xreq . open ( "GET" , exampleFileName ) ;
425- xreq . responseType = "arraybuffer" ;
426- xreq . send ( ) ;
422+ const data = Buffer . from ( await response . arrayBuffer ( ) ) ;
423+ loadData ( exampleFileName , data ) ;
424+ } ) ;
427425 } ) ;
428426
429427 // keyboard shortcuts
You can’t perform that action at this time.
0 commit comments