@@ -500,12 +500,12 @@ function SampleWidget() {
500500 ""
501501 ) ;
502502
503- this . _trimBtn = widgetWindow . addButton (
504- "trim.svg" ,
505- ICONSIZE ,
506- _ ( "Trim" ) ,
507- ""
508- ) ;
503+ // this._trimBtn = widgetWindow.addButton(
504+ // "trim.svg",
505+ // ICONSIZE,
506+ // _("Trim"),
507+ // ""
508+ // );
509509
510510 let generating = false ;
511511
@@ -672,159 +672,159 @@ function SampleWidget() {
672672 container . appendChild ( buttonDiv ) ;
673673 } ;
674674
675- this . _trimBtn . onclick = ( ) => {
676-
677- this . widgetWindow . clearScreen ( ) ;
678- let width , height ;
679- if ( ! this . widgetWindow . isMaximized ( ) ) {
680- width = SAMPLEWIDTH ;
681- height = SAMPLEHEIGHT ;
682- } else {
683- width = this . widgetWindow . getWidgetBody ( ) . getBoundingClientRect ( ) . width ;
684- height = this . widgetWindow . getWidgetFrame ( ) . getBoundingClientRect ( ) . height - 70 ;
685- }
686-
687- const container = document . createElement ( "div" ) ;
688- container . id = "samplerPrompt" ;
689- this . widgetWindow . getWidgetBody ( ) . appendChild ( container ) ;
690-
691- container . style . height = height + "px" ;
692- container . style . width = width + "px" ;
693- container . style . display = "flex" ;
694- container . style . flexDirection = "column" ;
695- container . style . alignItems = "center" ;
696- container . style . justifyContent = "center" ;
697- container . style . gap = "20px" ;
698-
699- const h1 = document . createElement ( "h1" ) ;
700- h1 . innerHTML = "Audio Trimmer" ;
701- h1 . style . fontSize = "40px" ;
702- h1 . style . marginTop = "0" ;
703- h1 . style . marginBottom = "0px" ;
704- h1 . style . fontWeight = "200" ;
705-
706- const divUploadSample = document . createElement ( "div" ) ;
707- divUploadSample . style . backgroundColor = "#8cc6ff" ;
708- divUploadSample . style . width = "50px" ;
709- divUploadSample . style . height = "50px" ;
710- divUploadSample . style . display = "flex" ;
711- divUploadSample . style . cursor = "pointer" ;
712- divUploadSample . style . justifyContent = "center" ;
713- divUploadSample . style . alignItems = "center" ;
714-
715- const uploadSample = document . createElement ( "img" ) ;
716- uploadSample . setAttribute ( "src" , "/header-icons/load-media.svg" ) ;
717- uploadSample . style . height = "32px" ;
718- uploadSample . style . width = "32px" ;
719-
720- divUploadSample . appendChild ( uploadSample ) ;
721-
722- const fileChooser = document . createElement ( "input" ) ;
723- fileChooser . type = "file" ;
724-
725- divUploadSample . onclick = function ( ) {
726- fileChooser . click ( ) ;
727- } ;
728-
729- fileChooser . onchange = function ( ) {
730- const file = fileChooser . files [ 0 ] ;
731- const audioPlayer = document . createElement ( "audio" ) ;
732- audioPlayer . controls = true ;
733- const fileURL = URL . createObjectURL ( file ) ;
734- audioPlayer . src = fileURL ;
735- container . replaceChild ( audioPlayer , divUploadSample ) ;
736- } ;
737-
738- const inputDiv = document . createElement ( "div" ) ;
739- inputDiv . style . width = "400px" ;
740- inputDiv . style . display = "flex" ;
741- inputDiv . style . justifyContent = "space-between" ;
742-
743- const fromInputBox = document . createElement ( "input" ) ;
744- fromInputBox . type = "text" ;
745- fromInputBox . title = "Enter start time (in seconds)" ;
746- fromInputBox . placeholder = "0.00" ;
747- fromInputBox . style . width = "152px" ;
748- fromInputBox . style . height = "61px" ;
749- fromInputBox . style . backgroundColor = "#FFFFFF" ;
750- fromInputBox . style . color = "#766C6C" ;
751- fromInputBox . style . fontSize = "32px" ;
752- fromInputBox . style . font = "Inter" ;
753- fromInputBox . style . borderRadius = "10px"
754- fromInputBox . style . border = "none"
755- fromInputBox . style . padding = "8px" ;
756- fromInputBox . style . textAlign = "center" ;
757- fromInputBox . type = "number" ;
758-
759- const toInputBox = document . createElement ( "input" ) ;
760- toInputBox . type = "text" ;
761- toInputBox . title = "Enter end time (in seconds)" ;
762- toInputBox . placeholder = "10.00" ;
763- toInputBox . style . width = "152px" ;
764- toInputBox . style . height = "61px" ;
765- toInputBox . style . backgroundColor = "#FFFFFF" ;
766- toInputBox . style . color = "#766C6C" ;
767- toInputBox . style . fontSize = "32px" ;
768- toInputBox . style . font = "Inter" ;
769- toInputBox . style . borderRadius = "10px" ;
770- toInputBox . style . border = "none" ;
771- toInputBox . style . padding = "8px" ;
772- toInputBox . style . textAlign = "center" ;
773- toInputBox . type = "number" ;
774-
775- inputDiv . appendChild ( fromInputBox ) ;
776- inputDiv . appendChild ( toInputBox ) ;
777-
778- const buttonDiv = document . createElement ( "div" ) ;
779- buttonDiv . style . width = "400px" ;
780- buttonDiv . style . display = "flex" ;
781- buttonDiv . style . justifyContent = "space-between" ;
782-
783- const preview = document . createElement ( "button" ) ;
784- preview . style . width = "152px" ;
785- preview . style . height = "61px" ;
786- preview . style . fontSize = "32px" ;
787- preview . style . borderRadius = "10px" ;
788- preview . style . border = "none" ;
789- preview . style . cursor = "pointer" ;
790- preview . innerHTML = "Preview" ;
791-
792- preview . onclick = async function ( ) {
793- const from = fromInputBox . value
794- const to = toInputBox . value
795- const audioURL = `http://13.61.94.100:8000/trim-preview?start=${ from } &end=${ to } ` ;
796- const audio = new Audio ( audioURL ) ;
797- audio . play ( ) ;
798- save . disabled = false ;
799- } ;
800-
801- const save = document . createElement ( "button" ) ;
802- save . style . width = "152px" ;
803- save . style . height = "61px" ;
804- save . style . fontSize = "32px" ;
805- save . style . borderRadius = "10px" ;
806- save . style . border = "none" ;
807- save . style . cursor = "pointer" ;
808- save . innerHTML = "Save" ;
809- save . disabled = true ;
810- save . onclick = function ( ) {
811- const audioURL = `http://13.61.94.100:8000/trim-save` ;
812- const link = document . createElement ( 'a' ) ;
813- link . href = audioURL ;
814- link . download = 'trimmed-output.wav' ;
815- document . body . appendChild ( link ) ;
816- link . click ( ) ;
817- document . body . removeChild ( link ) ;
818- } ;
819-
820- buttonDiv . appendChild ( preview ) ;
821- buttonDiv . appendChild ( save ) ;
822-
823- container . appendChild ( h1 ) ;
824- container . appendChild ( divUploadSample ) ;
825- container . appendChild ( inputDiv ) ;
826- container . appendChild ( buttonDiv ) ;
827- } ;
675+ // this._trimBtn.onclick = () => {
676+
677+ // this.widgetWindow.clearScreen();
678+ // let width, height;
679+ // if (!this.widgetWindow.isMaximized()) {
680+ // width = SAMPLEWIDTH;
681+ // height = SAMPLEHEIGHT;
682+ // } else {
683+ // width = this.widgetWindow.getWidgetBody().getBoundingClientRect().width;
684+ // height = this.widgetWindow.getWidgetFrame().getBoundingClientRect().height - 70;
685+ // }
686+
687+ // const container = document.createElement("div");
688+ // container.id = "samplerPrompt";
689+ // this.widgetWindow.getWidgetBody().appendChild(container);
690+
691+ // container.style.height = height + "px";
692+ // container.style.width = width + "px";
693+ // container.style.display = "flex";
694+ // container.style.flexDirection = "column";
695+ // container.style.alignItems = "center";
696+ // container.style.justifyContent = "center";
697+ // container.style.gap = "20px";
698+
699+ // const h1 = document.createElement("h1");
700+ // h1.innerHTML = "Audio Trimmer";
701+ // h1.style.fontSize = "40px";
702+ // h1.style.marginTop = "0";
703+ // h1.style.marginBottom = "0px";
704+ // h1.style.fontWeight = "200";
705+
706+ // const divUploadSample = document.createElement("div");
707+ // divUploadSample.style.backgroundColor = "#8cc6ff";
708+ // divUploadSample.style.width = "50px";
709+ // divUploadSample.style.height = "50px";
710+ // divUploadSample.style.display = "flex";
711+ // divUploadSample.style.cursor = "pointer";
712+ // divUploadSample.style.justifyContent = "center";
713+ // divUploadSample.style.alignItems = "center";
714+
715+ // const uploadSample = document.createElement("img");
716+ // uploadSample.setAttribute("src", "/header-icons/load-media.svg");
717+ // uploadSample.style.height = "32px";
718+ // uploadSample.style.width = "32px";
719+
720+ // divUploadSample.appendChild(uploadSample);
721+
722+ // const fileChooser = document.createElement("input");
723+ // fileChooser.type = "file";
724+
725+ // divUploadSample.onclick = function () {
726+ // fileChooser.click();
727+ // };
728+
729+ // fileChooser.onchange = function () {
730+ // const file = fileChooser.files[0];
731+ // const audioPlayer = document.createElement("audio");
732+ // audioPlayer.controls = true;
733+ // const fileURL = URL.createObjectURL(file);
734+ // audioPlayer.src = fileURL;
735+ // container.replaceChild(audioPlayer, divUploadSample);
736+ // };
737+
738+ // const inputDiv = document.createElement("div");
739+ // inputDiv.style.width = "400px";
740+ // inputDiv.style.display = "flex";
741+ // inputDiv.style.justifyContent = "space-between";
742+
743+ // const fromInputBox = document.createElement("input");
744+ // fromInputBox.type = "text";
745+ // fromInputBox.title = "Enter start time (in seconds)";
746+ // fromInputBox.placeholder = "0.00";
747+ // fromInputBox.style.width = "152px";
748+ // fromInputBox.style.height = "61px";
749+ // fromInputBox.style.backgroundColor = "#FFFFFF";
750+ // fromInputBox.style.color = "#766C6C";
751+ // fromInputBox.style.fontSize = "32px";
752+ // fromInputBox.style.font = "Inter";
753+ // fromInputBox.style.borderRadius = "10px"
754+ // fromInputBox.style.border = "none"
755+ // fromInputBox.style.padding = "8px";
756+ // fromInputBox.style.textAlign = "center";
757+ // fromInputBox.type = "number";
758+
759+ // const toInputBox = document.createElement("input");
760+ // toInputBox.type = "text";
761+ // toInputBox.title = "Enter end time (in seconds)";
762+ // toInputBox.placeholder = "10.00";
763+ // toInputBox.style.width = "152px";
764+ // toInputBox.style.height = "61px";
765+ // toInputBox.style.backgroundColor = "#FFFFFF";
766+ // toInputBox.style.color = "#766C6C";
767+ // toInputBox.style.fontSize = "32px";
768+ // toInputBox.style.font = "Inter";
769+ // toInputBox.style.borderRadius = "10px";
770+ // toInputBox.style.border = "none";
771+ // toInputBox.style.padding = "8px";
772+ // toInputBox.style.textAlign = "center";
773+ // toInputBox.type = "number";
774+
775+ // inputDiv.appendChild(fromInputBox);
776+ // inputDiv.appendChild(toInputBox);
777+
778+ // const buttonDiv = document.createElement("div");
779+ // buttonDiv.style.width = "400px";
780+ // buttonDiv.style.display = "flex";
781+ // buttonDiv.style.justifyContent = "space-between";
782+
783+ // const preview = document.createElement("button");
784+ // preview.style.width = "152px";
785+ // preview.style.height = "61px";
786+ // preview.style.fontSize = "32px";
787+ // preview.style.borderRadius = "10px";
788+ // preview.style.border = "none";
789+ // preview.style.cursor = "pointer";
790+ // preview.innerHTML = "Preview";
791+
792+ // preview.onclick = async function() {
793+ // const from = fromInputBox.value
794+ // const to = toInputBox.value
795+ // const audioURL = `http://13.61.94.100:8000/trim-preview?start=${from}&end=${to}`;
796+ // const audio = new Audio(audioURL);
797+ // audio.play();
798+ // save.disabled = false;
799+ // };
800+
801+ // const save = document.createElement("button");
802+ // save.style.width = "152px";
803+ // save.style.height = "61px";
804+ // save.style.fontSize = "32px";
805+ // save.style.borderRadius = "10px";
806+ // save.style.border = "none";
807+ // save.style.cursor = "pointer";
808+ // save.innerHTML = "Save";
809+ // save.disabled = true;
810+ // save.onclick = function (){
811+ // const audioURL = `http://13.61.94.100:8000/trim-save`;
812+ // const link = document.createElement('a');
813+ // link.href = audioURL;
814+ // link.download = 'trimmed-output.wav';
815+ // document.body.appendChild(link);
816+ // link.click();
817+ // document.body.removeChild(link);
818+ // };
819+
820+ // buttonDiv.appendChild(preview);
821+ // buttonDiv.appendChild(save);
822+
823+ // container.appendChild(h1);
824+ // container.appendChild(divUploadSample);
825+ // container.appendChild(inputDiv);
826+ // container.appendChild(buttonDiv);
827+ // };
828828
829829 this . _playbackBtn . id = "playbackBtn" ;
830830 this . _playbackBtn . classList . add ( "disabled" ) ;
0 commit comments