From 87b4f97c7f7552dfe3399fe948b1aa80a571387d Mon Sep 17 00:00:00 2001 From: Sema Date: Wed, 5 Jul 2023 22:46:29 -0400 Subject: [PATCH] New release --- minified/JZZ.gui.Player.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/minified/JZZ.gui.Player.js b/minified/JZZ.gui.Player.js index 89b6681..6bb5cfd 100644 --- a/minified/JZZ.gui.Player.js +++ b/minified/JZZ.gui.Player.js @@ -1 +1 @@ -!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t.Player=t:"function"==typeof define&&define.amd?define("JZZ.gui.Player",["JZZ","JZZ.midi.SMF"],t):t(JZZ)}(function(p){var r,h,d,c,u,y,f,_,v,g;function e(){}function m(t){this.div=document.createElement("div"),this.div.style.display="inline-block",this.div.style.position="absolute",this.div.style.boxSizing="content-box",this.div.style.top="8px",this.div.style.margin="0",this.div.style.padding="2px",this.div.style.borderStyle="solid",this.div.style.borderWidth="1px",this.div.style.borderColor="#aaa",this.div.style.backgroundColor="#888",this.div.style.lineHeight="0",this.div.style.lineSpasing="0",this.div.style.width="18px",this.div.style.height="18px",this.div.innerHTML=t}function B(t){t.stopPropagation(),t.preventDefault()}function b(t,i){if(!(this instanceof b))return new b(t,i);var e,o,s,n,l={at:void 0,x:void 0,y:void 0,play:!0,record:!1,pause:!0,stop:!0,loop:!0,file:!1,link:!1,midi:!0,close:!1,sndoff:!0,ports:[void 0,/MIDI Through/i],connect:!0};if("object"==typeof t)for(var p in l)l.hasOwnProperty(p)&&void 0!==t[p]&&(l[p]=t[p]);if(void 0===l.at&&(l.at=t),void 0===l.x&&(l.x=t),void 0===l.y&&(l.y=i),i=l,(e=this).gui=document.createElement("div"),e.gui.style.display="inline-block",e.gui.style.position="relative",e.gui.style.boxSizing="content-box",e.gui.style.margin="0px",e.gui.style.padding="0px",e.gui.style.borderStyle="none",e.gui.style.backgroundColor="#888",e.gui.style.width="270px",e.gui.style.height="40px",o=8,s=238,n=28,i.play?(e.playBtn=new m(h),e.playBtn.div.style.left=o+"px",o+=n,e.playBtn.div.title="play",e.playBtn.div.addEventListener("click",function(){e.play()}),e.gui.appendChild(e.playBtn.div)):e.playBtn=r,i.pause?(e.pauseBtn=new m(d),e.pauseBtn.div.style.left=o+"px",o+=n,e.pauseBtn.div.title="pause",e.pauseBtn.div.addEventListener("click",function(){e.pause()}),e.gui.appendChild(e.pauseBtn.div)):e.pauseBtn=r,i.stop?(e.stopBtn=new m(c),e.stopBtn.div.style.left=o+"px",o+=n,e.stopBtn.div.title="stop",e.stopBtn.div.addEventListener("click",function(){e.stop()}),e.gui.appendChild(e.stopBtn.div)):e.stopBtn=r,i.loop?(e.loopBtn=new m(u),e.loopBtn.div.style.left=o+"px",o+=n,e.loopBtn.div.title="loop",e.loopBtn.div.addEventListener("click",function(){e.loop()}),e.gui.appendChild(e.loopBtn.div)):e.loopBtn=r,i.midi?(e.midiBtn=new m(y),e.midiBtn.div.style.left=s+"px",s-=n,e.midiBtn.div.title="midi",e.midiBtn.div.addEventListener("click",function(){e.settings()}),e.gui.appendChild(e.midiBtn.div),e.sel=document.createElement("select"),e.sel.style.position="absolute",e.sel.style.top="30px",e.sel.style.left="40px",e.sel.style.width="230px",e.sel.style.display="none",e.sel.style.zIndex=1,e.sel.addEventListener("click",function(){e._selected()}),e.sel.addEventListener("keydown",function(t){e._keydown(t)}),e.sel.addEventListener("focusout",function(){e._closeselect()}),e.gui.appendChild(e.sel)):e.midiBtn=r,i.link&&(e.linkBtn=new m(_),e.linkBtn.div.style.left=s+"px",s-=n,e.linkBtn.div.title="link",e.gui.appendChild(e.linkBtn.div)),i.file?(e.fileBtn=new m(f),e.fileBtn.div.style.left=s+"px",s-=n,e.fileBtn.div.title="file",e.gui.appendChild(e.fileBtn.div),e.fileInput=document.createElement("input"),e.fileInput.type="file",e.fileInput.style.position="fixed",e.fileInput.style.visibility="hidden",e.fileInput.accept=".mid, .midi, .kar, .rmi, .syx",e.gui.appendChild(e.fileInput),window.FileReader&&(e.fileBtn.off(),e.fileBtn.div.addEventListener("click",function(){e.fileInput.click()}),e.fileInput.addEventListener("change",function(t){B(t),t.target.files[0]&&e.readFile(t.target.files[0])}),e.gui.addEventListener("drop",function(t){B(t),e.fileBtn.off(),e.readFile(t.dataTransfer.files[0])}),e.gui.addEventListener("dragover",function(t){B(t),e.fileBtn.on(),t.dataTransfer.dropEffect="copy"}),e.gui.addEventListener("dragexit",function(t){B(t),e.fileBtn.off()}))):e.fileBtn=r,i.close&&(e.closeBtn=document.createElement("div"),e.closeBtn.style.display="inline-block",e.closeBtn.style.position="absolute",e.closeBtn.style.boxSizing="content-box",e.closeBtn.style.top="1px",e.closeBtn.style.left="262px",e.closeBtn.style.margin="0",e.closeBtn.style.padding="0",e.closeBtn.style.backgroundColor="#f44",e.closeBtn.style.width="7px",e.closeBtn.style.height="7px",e.closeBtn.style.lineHeight="0",e.closeBtn.style.lineSpasing="0",e.closeBtn.innerHTML=v,e.closeBtn.title="close",e.closeBtn.addEventListener("click",function(){e.destroy()}),e.gui.appendChild(e.closeBtn)),e.rlen=s-o+10,e.lbl=document.createElement("div"),e.lbl.style.display="inline-block",e.lbl.style.position="absolute",e.lbl.style.top="26px",e.lbl.style.left=o+"px",e.lbl.style.width=e.rlen+10+"px",e.lbl.style.height="12px",e.lbl.style.padding="0",e.lbl.style.textAlign="center",e.lbl.style.color="#aaa",e.lbl.style.fontSize="12px",e.lbl.style.fontFamily="Arial, Helvetica, sans-serif",e.gui.appendChild(e.lbl),e.rail=document.createElement("div"),e.rail.style.display="inline-block",e.rail.style.position="absolute",e.rail.style.boxSizing="content-box",e.rail.style.top="19px",e.rail.style.left=o+5+"px",e.rail.style.width=e.rlen+"px",e.rail.style.height="0",e.rail.style.padding="1px",e.rail.style.borderStyle="solid",e.rail.style.borderWidth="1px",e.rail.style.borderRadius="2px",e.rail.style.borderColor="#aaa",e.rail.style.backgroundColor="#888",e.gui.appendChild(e.rail),e.caret=document.createElement("div"),e.caret.style.display="inline-block",e.caret.style.position="absolute",e.caret.style.boxSizing="content-box",e.caret.style.width="2px",e.caret.style.height="2px",e.caret.style.top="-5px",e.caret.style.left="-5px",e.caret.style.padding="4px",e.caret.style.borderStyle="solid",e.caret.style.borderWidth="1px",e.caret.style.borderRadius="6px",e.caret.style.borderColor="#aaa",e.caret.style.backgroundColor="#888",e.caret.addEventListener("mousedown",function(t){e._mousedown(t)}),e.rail.appendChild(e.caret),window.addEventListener("mousemove",function(t){e._mousemove(t)}),window.addEventListener("mouseup",function(t){e._mouseup(t)}),l.ports instanceof Array||(l.ports=[l.ports]),l.ports.push(void 0),this._ports=l.ports,this._conn=l.connect,this._sndoff=l.sndoff,this.disable(),"string"==typeof l.at)try{return document.getElementById(l.at).appendChild(this.gui),this}catch(t){}try{return l.at.appendChild(this.gui),this}catch(t){}l.x==parseInt(l.x)&&l.y==parseInt(l.y)||(l.x=15*g+5,l.y=45*g+5,g++),this.gui.style.position="fixed",this.gui.style.top=l.y+"px",this.gui.style.left=l.x+"px",this.gui.style.opacity=.9;var a=this;this.gui.addEventListener("mousedown",function(t){a._startmove(t)}),document.body.appendChild(this.gui)}function i(t){return void 0===t.buttons?!t.button:1&t.buttons}p.gui||(p.gui={}),p.gui.Player||(r={on:e,off:e,disable:e,title:e,div:{}},m.prototype.on=function(){this.div.style.backgroundColor="#ddd",this.div.style.borderColor="#ccc",this.div.firstChild.style.fill="#000"},m.prototype.off=function(){this.div.style.backgroundColor="#aaa",this.div.style.borderColor="#ccc",this.div.firstChild.style.fill="#000"},m.prototype.disable=function(){this.div.style.backgroundColor="#888",this.div.style.borderColor="#aaa",this.div.firstChild.style.fill="#555"},m.prototype.title=function(t){this.div.title=t},h='',d='',c='',u='',y='',f='',_='',v='',g=0,((b.prototype=new p.Widget).constructor=b).prototype.label=function(t){this.lbl.innerHTML=t},b.prototype.disable=function(){this.playBtn.disable(),this.pauseBtn.disable(),this.stopBtn.disable(),this.loopBtn.disable(),this.midiBtn.disable(),this._conn&&this.midiBtn.off(),this.fileBtn.off(),this.rail.style.borderColor="#aaa",this.rail.style.backgroundColor="#888",this.caret.style.borderColor="#aaa",this.caret.style.backgroundColor="#888"},b.prototype.enable=function(){this.playBtn.off(),this.pauseBtn.off(),this.stopBtn.off(),this.loopBtn.off(),this._conn&&this.midiBtn.off(),this.rail.style.borderColor="#ccc",this.caret.style.backgroundColor="#aaa",this.caret.style.borderColor="#ccc"},b.prototype.load=function(t){var i=this;this._player=t.player(),this._player.trim(),this._player.connect(this),this._player.onEnd=function(){i._onEnd()},this._player.filter(this._setfilter),this._sndoff||(this._player.sndOff=e),this.enable(),this.onLoad(t)},b.prototype.filter=function(t){this._setfilter=t instanceof Function?t:void 0,this._player&&this._player.filter(this._setfilter)},b.prototype.onSelect=e,b.prototype.onEnd=e,b.prototype.onLoad=e,b.prototype._onEnd=function(){this.onEnd(),this._loop&&-1!=this._loop&&this._loop--,this._loop?1==this._loop?(this._loop=0,this.loopBtn.off(),this.loopBtn.title("loop")):this.loopBtn.title("loop: "+(-1==this._loop?"∞":this._loop)):(this._moving&&clearInterval(this._moving),this._move(),this._playing=!1,this.playBtn.off())},b.prototype._move=function(){var t=Math.round(this._player.positionMS()*this.rlen/this._player.durationMS())-5;this.caret.style.left=t+"px"},b.prototype.onPlay=e,b.prototype.onResume=e,b.prototype._resume=function(){var t=this;this._player.resume(),this._moving=setInterval(function(){t._move()},100)},b.prototype.play=function(){var t;this._player&&((t=this).playBtn.on(),this.pauseBtn.off(),this._playing||(this._paused?this.onResume():this.onPlay(),this._playing=!0,this._paused=!1,this._out||!this._conn?this._resume():this._waiting||(this._waiting=!0,p().openMidiOut(t._ports).and(function(){t._out=this,t._outname=this.name(),t.midiBtn.title(t._outname),t._connect(this),t._waiting=!1,t.onSelect(t._outname),t._playing&&t._resume()}).or(function(){t._waiting=!1,t._resume()}))))},b.prototype.onStop=e,b.prototype.stop=function(){var t;this._player&&((t=this)._player.stop(),p.lib.schedule(function(){t.onStop()}),this._moving&&clearInterval(this._moving),this._playing=!1,this._paused=!1,this.playBtn.off(),this.pauseBtn.off(),this._move())},b.prototype.onPause=e,b.prototype.pause=function(t){var i;this._player&&((i=this)._paused?void 0!==t&&!t||(this._out?(this._resume(),this.onResume(),this._playing=!0,this._paused=!1,this.playBtn.on(),this.pauseBtn.off()):this.play()):!this._playing||void 0!==t&&t||(this._player.pause(),p.lib.schedule(function(){i.onPause()}),this._moving&&clearInterval(this._moving),this._playing=!1,this._paused=!0,this.playBtn.off(),this.pauseBtn.on()))},b.prototype.onLoop=e,b.prototype.loop=function(t){this._player&&((t=void 0===t?!this._loop:t)==parseInt(t)&&0this.rlen&&(i=this.rlen),this.jumpMS(this.durationMS()*i*1/this.rlen)):void 0!==this._startX&&(t.preventDefault(),this.gui.style.left=this._startX-this._clickX+t.clientX+"px",this.gui.style.top=this._startY-this._clickY+t.clientY+"px")},b.prototype._connect=b.prototype.connect,b.prototype._disconnect=b.prototype.disconnect,b.prototype.connect=function(t){t==this?(this._conn=!0,this.midiBtn.off()):this._connect(t)},b.prototype.disconnect=function(t){t==this?(this._conn=!1,this._out&&this._disconnect(this._out),this._outname=void 0,this.midiBtn.disable()):this._disconnect(t)},b.prototype.connected=function(){return this._outname},p.gui.Player=b,p.gui.Player.Btn=m)}); \ No newline at end of file +!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t.Player=t:"function"==typeof define&&define.amd?define("JZZ.gui.Player",["JZZ","JZZ.midi.SMF"],t):t(JZZ)}(function(r){var p,d,h;function e(){}function c(t){this.div=document.createElement("div"),this.div.style.display="inline-block",this.div.style.position="absolute",this.div.style.boxSizing="content-box",this.div.style.top="8px",this.div.style.margin="0",this.div.style.padding="2px",this.div.style.borderRadius=d.btn.borderRadius,this.div.style.borderStyle="solid",this.div.style.borderWidth=d.container.borderWidth,this.div.style.borderColor=d.btn.borderColor.disable,this.div.style.backgroundColor=d.btn.backgroundColor.disable,this.div.style.lineHeight="0",this.div.style.lineSpasing="0",this.div.style.width="18px",this.div.style.height="18px",this.div.innerHTML=t}function u(t){t.stopPropagation(),t.preventDefault()}function y(t,i){if(!(this instanceof y))return new y(t,i);var e,o,s,n,l={at:void 0,x:void 0,y:void 0,play:!0,record:!1,pause:!0,stop:!0,loop:!0,file:!1,link:!1,midi:!0,close:!1,sndoff:!0,ports:[void 0,/MIDI Through/i],connect:!0};if("object"==typeof t)for(var r in l)l.hasOwnProperty(r)&&void 0!==t[r]&&(l[r]=t[r]);if(void 0===l.at&&(l.at=t),void 0===l.x&&(l.x=t),void 0===l.y&&(l.y=i),i=l,(e=this).gui=document.createElement("div"),e.gui.style.display="inline-block",e.gui.style.position="relative",e.gui.style.boxSizing="content-box",e.gui.style.margin="0px",e.gui.style.padding="0px",e.gui.style.borderRadius=d.container.borderRadius,e.gui.style.borderStyle="none",e.gui.style.backgroundColor=d.container.backgroundColor,e.gui.style.width="270px",e.gui.style.height="40px",o=8,s=238,n=28,i.play?(e.playBtn=new c(d.svg.play),e.playBtn.div.style.left=o+"px",o+=n,e.playBtn.div.title="play",e.playBtn.div.addEventListener("click",function(){e.play()}),e.gui.appendChild(e.playBtn.div)):e.playBtn=p,i.pause?(e.pauseBtn=new c(d.svg.pause),e.pauseBtn.div.style.left=o+"px",o+=n,e.pauseBtn.div.title="pause",e.pauseBtn.div.addEventListener("click",function(){e.pause()}),e.gui.appendChild(e.pauseBtn.div)):e.pauseBtn=p,i.stop?(e.stopBtn=new c(d.svg.stop),e.stopBtn.div.style.left=o+"px",o+=n,e.stopBtn.div.title="stop",e.stopBtn.div.addEventListener("click",function(){e.stop()}),e.gui.appendChild(e.stopBtn.div)):e.stopBtn=p,i.loop?(e.loopBtn=new c(d.svg.loop),e.loopBtn.div.style.left=o+"px",o+=n,e.loopBtn.div.title="loop",e.loopBtn.div.addEventListener("click",function(){e.loop()}),e.gui.appendChild(e.loopBtn.div)):e.loopBtn=p,i.midi?(e.midiBtn=new c(d.svg.more),e.midiBtn.div.style.left=s+"px",s-=n,e.midiBtn.div.title="midi",e.midiBtn.div.addEventListener("click",function(){e.settings()}),e.gui.appendChild(e.midiBtn.div),e.sel=document.createElement("select"),e.sel.style.position="absolute",e.sel.style.top="30px",e.sel.style.left="40px",e.sel.style.width="230px",e.sel.style.display="none",e.sel.style.zIndex=1,e.sel.addEventListener("click",function(){e._selected()}),e.sel.addEventListener("keydown",function(t){e._keydown(t)}),e.sel.addEventListener("focusout",function(){e._closeselect()}),e.gui.appendChild(e.sel)):e.midiBtn=p,i.link&&(e.linkBtn=new c(d.svg.link),e.linkBtn.div.style.left=s+"px",s-=n,e.linkBtn.div.title="link",e.gui.appendChild(e.linkBtn.div)),i.file?(e.fileBtn=new c(d.svg.open),e.fileBtn.div.style.left=s+"px",s-=n,e.fileBtn.div.title="file",e.gui.appendChild(e.fileBtn.div),e.fileInput=document.createElement("input"),e.fileInput.type="file",e.fileInput.style.position="fixed",e.fileInput.style.visibility="hidden",e.fileInput.accept=".mid, .midi, .kar, .rmi, .syx",e.gui.appendChild(e.fileInput),window.FileReader&&(e.fileBtn.off(),e.fileBtn.div.addEventListener("click",function(){e.fileInput.click()}),e.fileInput.addEventListener("change",function(t){u(t),t.target.files[0]&&e.readFile(t.target.files[0])}),e.gui.addEventListener("drop",function(t){u(t),e.fileBtn.off(),e.readFile(t.dataTransfer.files[0])}),e.gui.addEventListener("dragover",function(t){u(t),e.fileBtn.on(),t.dataTransfer.dropEffect="copy"}),e.gui.addEventListener("dragexit",function(t){u(t),e.fileBtn.off()}))):e.fileBtn=p,i.close&&(e.closeBtn=document.createElement("div"),e.closeBtn.style.display="inline-block",e.closeBtn.style.position="absolute",e.closeBtn.style.boxSizing="content-box",e.closeBtn.style.top="1px",e.closeBtn.style.left="262px",e.closeBtn.style.margin="0",e.closeBtn.style.padding="0",e.closeBtn.style.borderRadius=d.btn.close.borderRadius,e.closeBtn.style.backgroundColor=d.btn.close.backgroundColor,e.closeBtn.style.width="7px",e.closeBtn.style.height="7px",e.closeBtn.style.lineHeight="0",e.closeBtn.style.lineSpasing="0",e.closeBtn.innerHTML=d.svg.close,e.closeBtn.title="close",e.closeBtn.addEventListener("click",function(){e.destroy()}),e.gui.appendChild(e.closeBtn)),e.rlen=s-o+10,e.lbl=document.createElement("div"),e.lbl.style.display="inline-block",e.lbl.style.position="absolute",e.lbl.style.top="26px",e.lbl.style.left=o+"px",e.lbl.style.width=e.rlen+10+"px",e.lbl.style.height="12px",e.lbl.style.padding="0",e.lbl.style.textAlign="center",e.lbl.style.color=d.lbl.color,e.lbl.style.fontSize=d.lbl.fontSize,e.lbl.style.fontFamily=d.lbl.fontFamily,e.gui.appendChild(e.lbl),e.rail=document.createElement("div"),e.rail.style.display="inline-block",e.rail.style.position="absolute",e.rail.style.boxSizing="content-box",e.rail.style.top="19px",e.rail.style.left=o+5+"px",e.rail.style.width=e.rlen+"px",e.rail.style.height="0",e.rail.style.padding="1px",e.rail.style.borderStyle="solid",e.rail.style.borderWidth=d.rail.borderWidth,e.rail.style.borderRadius=d.rail.borderRadius,e.rail.style.borderColor=d.rail.borderColor.disable,e.rail.style.backgroundColor=d.rail.backgroundColor.disable,e.gui.appendChild(e.rail),e.caret=document.createElement("div"),e.caret.style.display="inline-block",e.caret.style.position="absolute",e.caret.style.boxSizing="content-box",e.caret.style.width="2px",e.caret.style.height="2px",e.caret.style.top="-5px",e.caret.style.left="-5px",e.caret.style.padding="4px",e.caret.style.borderStyle="solid",e.caret.style.borderWidth=d.caret.borderWidth,e.caret.style.borderRadius=d.caret.borderRadius,e.caret.style.borderColor=d.caret.borderColor.disable,e.caret.style.backgroundColor=d.caret.backgroundColor.disable,e.caret.addEventListener("mousedown",function(t){e._mousedown(t)}),e.rail.appendChild(e.caret),window.addEventListener("mousemove",function(t){e._mousemove(t)}),window.addEventListener("mouseup",function(t){e._mouseup(t)}),l.ports instanceof Array||(l.ports=[l.ports]),l.ports.push(void 0),this._ports=l.ports,this._conn=l.connect,this._sndoff=l.sndoff,this.disable(),"string"==typeof l.at)try{return document.getElementById(l.at).appendChild(this.gui),this}catch(t){}try{return l.at.appendChild(this.gui),this}catch(t){}l.x==parseInt(l.x)&&l.y==parseInt(l.y)||(l.x=15*h+5,l.y=45*h+5,h++),this.gui.style.position="fixed",this.gui.style.top=l.y+"px",this.gui.style.left=l.x+"px",this.gui.style.opacity=.9;var a=this;this.gui.addEventListener("mousedown",function(t){a._startmove(t)}),document.body.appendChild(this.gui)}function i(t){return void 0===t.buttons?!t.button:1&t.buttons}r.gui||(r.gui={}),r.gui.Player||(p={on:e,off:e,disable:e,title:e,div:{}},d={container:{backgroundColor:"#888",borderRadius:"0px",borderWidth:"1px"},lbl:{color:"#aaa",fontSize:"12px",fontFamily:"Arial, Helvetica, sans-serif"},btn:{borderRadius:"0px",backgroundColor:{on:"#ddd",off:"#aaa",disable:"#888"},borderColor:{on:"#ccc",off:"#ccc",disable:"#aaa"},svgFill:{on:"#000",off:"#000",disable:"#555"},close:{borderRadius:"0px",backgroundColor:"#f44"}},rail:{borderRadius:"2px",borderWidth:"1px",backgroundColor:{enable:"#ccc",disable:"#888"},borderColor:{enable:"#ccc",disable:"#aaa"}},caret:{borderRadius:"6px",borderWidth:"1px",backgroundColor:{mouseDown:"#ddd",mouseUp:"#aaa",enable:"#aaa",disable:"#888"},borderColor:{enable:"#ccc",disable:"#aaa"}},svg:{play:'',pause:'',stop:'',loop:'',more:'',open:'',link:'',close:''}},c.prototype.on=function(){this.div.style.backgroundColor=d.btn.backgroundColor.on,this.div.style.borderColor=d.btn.borderColor.on,this.div.firstChild.style.fill=d.btn.svgFill.on},c.prototype.off=function(){this.div.style.backgroundColor=d.btn.backgroundColor.off,this.div.style.borderColor=d.btn.borderColor.off,this.div.firstChild.style.fill=d.btn.svgFill.off},c.prototype.disable=function(){this.div.style.backgroundColor=d.btn.backgroundColor.disable,this.div.style.borderColor=d.btn.borderColor.disable,this.div.firstChild.style.fill=d.btn.svgFill.disable},c.prototype.title=function(t){this.div.title=t},h=0,((y.prototype=new r.Widget).constructor=y).prototype.label=function(t){this.lbl.innerHTML=t},y.prototype.disable=function(){this.playBtn.disable(),this.pauseBtn.disable(),this.stopBtn.disable(),this.loopBtn.disable(),this.midiBtn.disable(),this._conn&&this.midiBtn.off(),this.fileBtn.off(),this.rail.style.borderColor=d.rail.borderColor.disable,this.rail.style.backgroundColor=d.rail.backgroundColor.disable,this.caret.style.borderColor=d.caret.borderColor.disable,this.caret.style.backgroundColor=d.caret.backgroundColor.disable},y.prototype.enable=function(){this.playBtn.off(),this.pauseBtn.off(),this.stopBtn.off(),this.loopBtn.off(),this._conn&&this.midiBtn.off(),this.rail.style.borderColor=d.rail.borderColor.enable,this.caret.style.backgroundColor=d.caret.backgroundColor.enable,this.caret.style.borderColor=d.caret.borderColor.enable},y.prototype.load=function(t){var i=this;this._player=t.player(),this._player.trim(),this._player.connect(this),this._player.onEnd=function(){i._onEnd()},this._player.filter(this._setfilter),this._sndoff||(this._player.sndOff=e),this.enable(),this.onLoad(t)},y.prototype.filter=function(t){this._setfilter=t instanceof Function?t:void 0,this._player&&this._player.filter(this._setfilter)},y.prototype.onSelect=e,y.prototype.onEnd=e,y.prototype.onLoad=e,y.prototype._onEnd=function(){this.onEnd(),this._loop&&-1!=this._loop&&this._loop--,this._loop?1==this._loop?(this._loop=0,this.loopBtn.off(),this.loopBtn.title("loop")):this.loopBtn.title("loop: "+(-1==this._loop?"∞":this._loop)):(this._moving&&clearInterval(this._moving),this._move(),this._playing=!1,this.playBtn.off())},y.prototype._move=function(){var t=Math.round(this._player.positionMS()*this.rlen/this._player.durationMS())-5;this.caret.style.left=t+"px"},y.prototype.onPlay=e,y.prototype.onResume=e,y.prototype._resume=function(){var t=this;this._player.resume(),this._moving=setInterval(function(){t._move()},100)},y.prototype.play=function(){var t;this._player&&((t=this).playBtn.on(),this.pauseBtn.off(),this._playing||(this._paused?this.onResume():this.onPlay(),this._playing=!0,this._paused=!1,this._out||!this._conn?this._resume():this._waiting||(this._waiting=!0,r().openMidiOut(t._ports).and(function(){t._out=this,t._outname=this.name(),t.midiBtn.title(t._outname),t._connect(this),t._waiting=!1,t.onSelect(t._outname),t._playing&&t._resume()}).or(function(){t._waiting=!1,t._resume()}))))},y.prototype.onStop=e,y.prototype.stop=function(){var t;this._player&&((t=this)._player.stop(),r.lib.schedule(function(){t.onStop()}),this._moving&&clearInterval(this._moving),this._playing=!1,this._paused=!1,this.playBtn.off(),this.pauseBtn.off(),this._move())},y.prototype.onPause=e,y.prototype.pause=function(t){var i;this._player&&((i=this)._paused?void 0!==t&&!t||(this._out?(this._resume(),this.onResume(),this._playing=!0,this._paused=!1,this.playBtn.on(),this.pauseBtn.off()):this.play()):!this._playing||void 0!==t&&t||(this._player.pause(),r.lib.schedule(function(){i.onPause()}),this._moving&&clearInterval(this._moving),this._playing=!1,this._paused=!0,this.playBtn.off(),this.pauseBtn.on()))},y.prototype.onLoop=e,y.prototype.loop=function(t){var i;this._player&&(i=this,(t=void 0===t?!this._loop:t)==parseInt(t)&&0this.rlen&&(i=this.rlen),this.jumpMS(this.durationMS()*i*1/this.rlen)):void 0!==this._startX&&(t.preventDefault(),this.gui.style.left=this._startX-this._clickX+t.clientX+"px",this.gui.style.top=this._startY-this._clickY+t.clientY+"px")},y.prototype._connect=y.prototype.connect,y.prototype._disconnect=y.prototype.disconnect,y.prototype.connect=function(t){t==this?(this._conn=!0,this.midiBtn.off()):this._connect(t)},y.prototype.disconnect=function(t){t==this?(this._conn=!1,this._out&&this._disconnect(this._out),this._outname=void 0,this.midiBtn.disable()):this._disconnect(t)},y.prototype.connected=function(){return this._outname},r.gui.Player=y,r.gui.Player.Btn=c,r.gui.Player.theme=d)}); \ No newline at end of file diff --git a/package.json b/package.json index 593a12f..26e89d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jzz-gui-player", - "version": "1.6.4", + "version": "1.6.5", "description": "MIDI Player GUI for browsers", "main": "javascript/JZZ.gui.Player.js", "scripts": {