|
34 | 34 | <div id="lblSettings" style="cursor:pointer;">🔧 Input Settings</div> |
35 | 35 | <div id="settingsPanel" style="padding-left:20px;"> |
36 | 36 | <div> |
37 | | - <div>Audio</div> |
| 37 | + <div>🔊 Audio</div> |
38 | 38 | <div style="padding-left:20px;"> |
39 | 39 | <div> |
40 | 40 | none |
|
53 | 53 | </div> |
54 | 54 | </div> |
55 | 55 | <div> |
56 | | - <div>Video</div> |
| 56 | + <div>📺 Video</div> |
57 | 57 | <div style="padding-left:20px;"> |
58 | 58 | <div> |
59 | 59 | none |
|
78 | 78 | </div> |
79 | 79 |
|
80 | 80 | <div>🎬 Stage</div> |
81 | | - <div> |
82 | | - <button id="btnRecord">Start Recording</button> |
| 81 | + <div style="display:flex;"> |
| 82 | + <button id="btnRecord">start recording</button> |
83 | 83 | <button id="btnPlay">play</button> |
| 84 | + <button id="btnClearStage">clear</button> |
| 85 | + <div style="flex:1;"></div> |
84 | 86 | <button id="btnDownloadMovie">download movie</button> |
| 87 | + <div style="flex:1;"></div> |
85 | 88 | <button id="btnNext">change canvas</button> |
86 | 89 | </div> |
87 | 90 |
|
88 | 91 | <div style="padding-left:20px;"> |
89 | | - <div>🛵 Tracks</div> |
90 | | - <div style="display:flex;flex-wrap: wrap;"> |
91 | | - <Component id="tracksView"></Component> |
| 92 | + <div id="lblTracks" style="display:none;"> |
| 93 | + <div>🛵 Tracks</div> |
| 94 | + <div style="display:flex;flex-wrap: wrap;"> |
| 95 | + <Component id="tracksView"></Component> |
| 96 | + </div> |
92 | 97 | </div> |
| 98 | + <script> |
| 99 | + /* |
| 100 | + Camera Hit Tracks |
| 101 | + Movie Hit Tracks |
| 102 | + Canvas Hit Tracks |
| 103 | + */ |
| 104 | + </script> |
93 | 105 | </div> |
94 | 106 | <div style="display:flex;padding-top:10px;padding-bottom:10px;"> |
95 | 107 | <div id="chkMic" style="display:none;padding:5px;background-color:gainsboro;border-radius:20px;padding-left:15px;padding-right:15px;margin-right:10px;">🔴 Mic</div> |
|
153 | 165 | hasVideoTracks : function () { for(var x = 0; x < this.tracks.length;x++) if(this.tracks[x].type == "video") return true; return false; } |
154 | 166 | }; |
155 | 167 |
|
| 168 | +btnClearStage.el.addEventListener("click",()=>{ |
| 169 | + self.app.tracks.splice(0,self.app.tracks.length); |
| 170 | + self.app.events.emit("updateTracks"); |
| 171 | +}); |
| 172 | + |
156 | 173 | lblSettings.el.addEventListener("click",()=>{ |
157 | 174 | if(self.app.panel.settings.visible) { |
158 | 175 | settingsPanel.el.style.display = "none"; |
|
352 | 369 | fileAudio.el.value = ""; |
353 | 370 | self.app.tracks.push(track); |
354 | 371 | console.log(track); |
355 | | - self.app.events.emit("addTrack"); |
| 372 | + self.app.events.emit("updateTracks"); |
356 | 373 | } |
357 | 374 | reader.readAsArrayBuffer(file); |
358 | 375 | } |
|
509 | 526 |
|
510 | 527 |
|
511 | 528 | function toggleRecording() { |
512 | | - if (btnRecord.el.textContent === 'Start Recording') { |
| 529 | + if (btnRecord.el.textContent === 'start recording') { |
513 | 530 | startRecording(); |
514 | 531 | } else { |
515 | 532 | stopRecording(); |
516 | | - btnRecord.el.textContent = 'Start Recording'; |
| 533 | + btnRecord.el.textContent = 'start recording'; |
517 | 534 | btnPlay.el.disabled = false; |
518 | 535 | btnDownloadMovie.el.disabled = false; |
519 | 536 | } |
|
546 | 563 |
|
547 | 564 | self.app.audio.control = schema.el.audio; |
548 | 565 |
|
| 566 | + self.app.events.off("hitTrack",self.app.events.hitTrack); |
| 567 | + delete self.app.events.hitTrack; |
| 568 | + |
549 | 569 | } else { |
550 | 570 | const superBuffer = new Blob(recordedBlobs, {type: 'video/webm'}); |
551 | 571 | playscreen.el.src = window.URL.createObjectURL(superBuffer); |
|
579 | 599 | } |
580 | 600 |
|
581 | 601 | if(self.app.hasAudioTracks()) { |
582 | | - |
583 | | - |
584 | | - //playback.start(); |
585 | | - self.app.events.on("hitTrack",(n)=>{ |
| 602 | + self.app.events.hitTrack = (n)=>{ |
586 | 603 | if(n < self.app.tracks.length && self.app.tracks[n].type == "audio") { |
587 | 604 | var playback = audioCtx.createBufferSource(); |
588 | 605 | var playbackGain = audioCtx.createGain(); |
|
594 | 611 | playback.start(); |
595 | 612 | } |
596 | 613 | console.log("hit",self.app.tracks[n]); |
597 | | - }); |
| 614 | + }; |
| 615 | + //playback.start(); |
| 616 | + self.app.events.on("hitTrack",self.app.events.hitTrack); |
598 | 617 |
|
599 | 618 | } |
600 | 619 |
|
|
647 | 666 | } |
648 | 667 |
|
649 | 668 | log('Created MediaRecorder', mediaRecorder, 'with options', options); |
650 | | - btnRecord.el.textContent = 'Stop Recording'; |
| 669 | + btnRecord.el.textContent = 'stop recording'; |
651 | 670 | btnPlay.el.disabled = true; |
652 | 671 | btnDownloadMovie.el.disabled = true; |
653 | 672 | mediaRecorder.onstop = handleStop; |
|
744 | 763 | .send(); |
745 | 764 | }); |
746 | 765 |
|
747 | | -self.app.events.on("addTrack",()=>{ |
| 766 | + |
| 767 | +self.app.events.on("updateTracks",()=>{ |
748 | 768 | // do not remove duplicate tracks cause it may be same track name for different folders |
749 | 769 | tracksView.$.elementsClear(); |
750 | 770 | async function addTrack(n,track) { |
751 | | - var schema = await tracksView.$.elementPushPacketAsync(` |
752 | | - <div style="display:flex;"> |
753 | | - <div style="padding-left:5px;padding-right:5px;">${(""+n).padStart(2,"0")}</div> |
754 | | - <div style="padding-left:5px;padding-right:5px;width:100px;overflow:hidden;white-space: nowrap;">${track.data.name}</div> |
755 | | - <div style="padding-left:5px;padding-right:5px;"><button id="btnHit">hit</button></div> |
756 | | - </div> |
757 | | - `); |
758 | | - schema.el.btnHit.addEventListener("click",()=>{ |
759 | | - self.app.events.emit("hitTrack",[n]); |
760 | | - }); |
| 771 | + if(track.type == "audio") { |
| 772 | + var schema = await tracksView.$.elementPushPacketAsync(` |
| 773 | + <div style="display:flex;"> |
| 774 | + <div style="padding-left:5px;padding-right:5px;">🔊 ${(""+n).padStart(2,"0")}</div> |
| 775 | + <div style="padding-left:5px;padding-right:5px;width:100px;overflow:hidden;white-space: nowrap;">${track.data.name}</div> |
| 776 | + <div style="padding-left:5px;padding-right:5px;"><button id="btnHit">hit</button></div> |
| 777 | + </div> |
| 778 | + `); |
| 779 | + schema.el.btnHit.addEventListener("click",()=>{ |
| 780 | + self.app.events.emit("hitTrack",[n]); |
| 781 | + }); |
| 782 | + } |
761 | 783 | } |
| 784 | + if(self.app.tracks.length>0) lblTracks.el.style.display = ""; |
| 785 | + else lblTracks.el.style.display = "none"; |
762 | 786 | for(var x =0; x < self.app.tracks.length;x++) { |
763 | 787 | addTrack(x,self.app.tracks[x]); |
764 | 788 | } |
765 | 789 | }); |
766 | 790 |
|
| 791 | + |
767 | 792 | async function addAsset(item) { |
768 | 793 | var visible = false; |
769 | 794 | var itemStruct = { |
|
840 | 865 | events : [] |
841 | 866 | }; |
842 | 867 | self.app.tracks.push(track); |
843 | | - self.app.events.emit("addTrack"); |
| 868 | + self.app.events.emit("updateTracks"); |
844 | 869 | console.log(track); |
845 | 870 | } else if(this.spec.type == "video.webm") { |
846 | 871 | throw new Error("video not implemented"); |
|
0 commit comments