mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-27 12:38:22 +01:00
445 lines
42 KiB
JavaScript
445 lines
42 KiB
JavaScript
|
(function() {
|
||
|
var MediaPlayer;
|
||
|
|
||
|
MediaPlayer = class MediaPlayer extends this.OS.GUI.BaseApplication {
|
||
|
constructor(args) {
|
||
|
super("MediaPlayer", args);
|
||
|
}
|
||
|
|
||
|
main() {
|
||
|
var me;
|
||
|
me = this;
|
||
|
this.volsw = this.find("play-vol");
|
||
|
this.volctl = this.find("vol-control");
|
||
|
this.volsw.set("swon", true);
|
||
|
this.volctl.set("onchange", function(v) {
|
||
|
if (!(me.volsw.get("swon"))) {
|
||
|
return;
|
||
|
}
|
||
|
return Howler.volume((me.volctl.get("value")) / 100);
|
||
|
});
|
||
|
this.volctl.set("value", 70);
|
||
|
this.playlist = this.find("playlist");
|
||
|
this.playtime = this.find("play-time");
|
||
|
this.songname = this.find("song-name");
|
||
|
this.totaltime = this.find("total-time");
|
||
|
this.playpause = this.find("play-pause");
|
||
|
this.progress = this.find("play-slide");
|
||
|
this.playran = this.find("play-random");
|
||
|
this.history = [];
|
||
|
this.currsong = void 0;
|
||
|
this.timer = void 0;
|
||
|
this.animator = this.find("animation");
|
||
|
this.volsw.set("onchange", function(e) {
|
||
|
if (!e.data) {
|
||
|
return Howler.volume(0);
|
||
|
}
|
||
|
return Howler.volume((me.volctl.get("value")) / 100);
|
||
|
});
|
||
|
this.playlist.set("buttons", [
|
||
|
{
|
||
|
text: "+",
|
||
|
onbtclick: function() {
|
||
|
return me.openDialog("FileDiaLog",
|
||
|
function(d,
|
||
|
n,
|
||
|
p,
|
||
|
f) {
|
||
|
if (f.type === "dir") {
|
||
|
return me.scanDir(f);
|
||
|
}
|
||
|
f.text = f.filename;
|
||
|
f.iconclass = "fa fa-music";
|
||
|
return me.playlist.push(f,
|
||
|
true);
|
||
|
},
|
||
|
"__(Select MP3 file or a folder)",
|
||
|
{
|
||
|
mimes: ["dir",
|
||
|
"audio/mpeg"]
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
text: "-",
|
||
|
onbtclick: function() {
|
||
|
var sel;
|
||
|
sel = me.playlist.get("selected");
|
||
|
if (!sel) {
|
||
|
return;
|
||
|
}
|
||
|
if (sel === me.currsong) {
|
||
|
me.stop();
|
||
|
}
|
||
|
return me.playlist.remove(sel,
|
||
|
true);
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
text: "",
|
||
|
onbtclick: function() {
|
||
|
return me.openDialog("PromptDialog",
|
||
|
function(link) {
|
||
|
var data;
|
||
|
if (!(link && link !== "")) {
|
||
|
return;
|
||
|
}
|
||
|
data = {
|
||
|
text: link,
|
||
|
path: link,
|
||
|
iconclass: "fa fa-link",
|
||
|
broadcast: true
|
||
|
};
|
||
|
return me.playlist.push(data,
|
||
|
true);
|
||
|
},
|
||
|
"__(MP3 Radio broadcast)",
|
||
|
{
|
||
|
label: "Enter radio broadcast link"
|
||
|
});
|
||
|
},
|
||
|
iconclass: "fa fa-link"
|
||
|
},
|
||
|
{
|
||
|
text: "",
|
||
|
iconclass: "fa fa-save",
|
||
|
onbtclick: function() {
|
||
|
var fp,
|
||
|
i,
|
||
|
len1,
|
||
|
playlist,
|
||
|
ref,
|
||
|
v;
|
||
|
playlist = [];
|
||
|
ref = me.playlist.get("items");
|
||
|
for (i = 0, len1 = ref.length; i < len1; i++) {
|
||
|
v = ref[i];
|
||
|
playlist.push({
|
||
|
text: v.text,
|
||
|
path: v.path,
|
||
|
iconclass: v.iconclass,
|
||
|
broadcast: v.broadcast ? v.broadcast : false
|
||
|
});
|
||
|
}
|
||
|
fp = "Untitled".asFileHandler();
|
||
|
return me.openDialog("FileDiaLog",
|
||
|
function(d,
|
||
|
n,
|
||
|
p,
|
||
|
f) {
|
||
|
fp = `${d}/${n}`.asFileHandler();
|
||
|
fp.cache = playlist;
|
||
|
return fp.write("object",
|
||
|
function(r) {
|
||
|
if (r.error) {
|
||
|
return me.error(__("Cannot save playlist: {0}",
|
||
|
r.error));
|
||
|
}
|
||
|
return me.notify(__("Playlist saved"));
|
||
|
});
|
||
|
},
|
||
|
"__(Save Playlist)",
|
||
|
{
|
||
|
file: fp
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
text: "",
|
||
|
iconclass: "fa fa-folder",
|
||
|
onbtclick: function() {
|
||
|
return me.openDialog("FileDiaLog",
|
||
|
function(d,
|
||
|
n,
|
||
|
p,
|
||
|
f) {
|
||
|
return f.path.asFileHandler().read(function(d) {
|
||
|
me.stop();
|
||
|
return me.playlist.set("items",
|
||
|
d);
|
||
|
},
|
||
|
"json");
|
||
|
},
|
||
|
"__(Open Playlist)",
|
||
|
{
|
||
|
mimes: ["application/json"]
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
]);
|
||
|
this.playlist.set("onlistdbclick", function(e) {
|
||
|
if (!e) {
|
||
|
return;
|
||
|
}
|
||
|
e.data.index = e.idx;
|
||
|
return me.play(e.data);
|
||
|
});
|
||
|
this.progress.set("onchange", function(s) {
|
||
|
return me.seek(s);
|
||
|
});
|
||
|
this.playpause.set("onchange", function(e) {
|
||
|
return me.togglePlayPause();
|
||
|
});
|
||
|
(this.find("play-prev")).set("onbtclick", function() {
|
||
|
return me.prevSong();
|
||
|
});
|
||
|
(this.find("play-next")).set("onbtclick", function() {
|
||
|
return me.nextSong();
|
||
|
});
|
||
|
return $(this.animator).css("visibility", "hidden");
|
||
|
}
|
||
|
|
||
|
scanDir(f) {
|
||
|
var me;
|
||
|
me = this;
|
||
|
return f.path.asFileHandler().read(function(d) {
|
||
|
var i, len1, ref, results, v;
|
||
|
if (d.error) {
|
||
|
return me.error(__("Unable to read {0}", d.error));
|
||
|
}
|
||
|
ref = d.result;
|
||
|
results = [];
|
||
|
for (i = 0, len1 = ref.length; i < len1; i++) {
|
||
|
v = ref[i];
|
||
|
if (!(v.mime.match(/audio\/mpeg/))) {
|
||
|
continue;
|
||
|
}
|
||
|
v.iconclass = "fa fa-music";
|
||
|
v.text = v.filename;
|
||
|
results.push(me.playlist.push(v, true));
|
||
|
}
|
||
|
return results;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
togglePlayPause() {
|
||
|
var sound;
|
||
|
if (!(this.currsong && this.currsong.howl)) {
|
||
|
return this.playpause.set("swon", false);
|
||
|
}
|
||
|
sound = this.currsong.howl;
|
||
|
if (sound.playing()) {
|
||
|
return sound.pause();
|
||
|
} else {
|
||
|
return sound.play();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
nextSong() {
|
||
|
var idx, len, sel;
|
||
|
idx = -1;
|
||
|
if (this.playran.get("swon")) {
|
||
|
idx = this.randomSong();
|
||
|
} else {
|
||
|
len = (this.playlist.get("items")).length;
|
||
|
if (len > 0) {
|
||
|
idx = 0;
|
||
|
if (this.currsong) {
|
||
|
idx = this.currsong.index + 1;
|
||
|
}
|
||
|
if (idx >= len) {
|
||
|
idx = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (idx === -1) {
|
||
|
return;
|
||
|
}
|
||
|
if (history.length >= 10) {
|
||
|
this.history.pop();
|
||
|
}
|
||
|
if (this.currsong) {
|
||
|
this.history.unshift(this.currsong.index);
|
||
|
}
|
||
|
this.playlist.set("selected", idx);
|
||
|
sel = this.playlist.get("selected");
|
||
|
sel.index = idx;
|
||
|
return this.play(sel);
|
||
|
}
|
||
|
|
||
|
prevSong() {
|
||
|
var idx, len, sel;
|
||
|
idx = -1;
|
||
|
if (this.playran.get("swon")) {
|
||
|
if (this.history.length > 0) {
|
||
|
idx = this.history.shift();
|
||
|
}
|
||
|
} else {
|
||
|
len = (this.playlist.get("items")).length;
|
||
|
if (len > 0) {
|
||
|
if (this.currsong) {
|
||
|
idx = this.currsong.index - 1;
|
||
|
}
|
||
|
if (idx < 0) {
|
||
|
idx = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (idx === -1) {
|
||
|
return;
|
||
|
}
|
||
|
this.playlist.set("selected", idx);
|
||
|
sel = this.playlist.get("selected");
|
||
|
sel.index = idx;
|
||
|
return this.play(sel);
|
||
|
}
|
||
|
|
||
|
randomSong() {
|
||
|
var len;
|
||
|
len = (this.playlist.get("items")).length;
|
||
|
if (!(len > 0)) {
|
||
|
return -1;
|
||
|
}
|
||
|
return Math.floor(Math.random() * Math.floor(len));
|
||
|
}
|
||
|
|
||
|
play(file) {
|
||
|
var me, sound;
|
||
|
me = this;
|
||
|
this.stop();
|
||
|
this.currsong = file;
|
||
|
sound = file.howl;
|
||
|
if (!sound) {
|
||
|
sound = file.howl = new Howl({
|
||
|
src: [file.path.asFileHandler().getlink()],
|
||
|
preload: true,
|
||
|
buffer: true,
|
||
|
html5: true, // Force to HTML5 so that the audio can stream in (best for large files).
|
||
|
format: ['mp3', 'aac'],
|
||
|
onplay: function() {
|
||
|
var duration, func;
|
||
|
$(me.animator).css("visibility", "visible");
|
||
|
//Display the duration.
|
||
|
me.playpause.set("swon", true);
|
||
|
console.log("play");
|
||
|
me.songname.set("text", file.text);
|
||
|
duration = Math.round(sound.duration());
|
||
|
if (duration !== 2e308) {
|
||
|
me.totaltime.set("text", me.formatDuration(duration));
|
||
|
me.progress.set("max", duration);
|
||
|
} else {
|
||
|
me.totaltime.set("text", "--:--");
|
||
|
me.progress.set("max", 0);
|
||
|
}
|
||
|
if (!file.broadcast) {
|
||
|
func = function() {
|
||
|
var seek;
|
||
|
if (sound.playing()) {
|
||
|
seek = Math.round(sound.seek()) || 0;
|
||
|
me.progress.set("value", seek);
|
||
|
me.playtime.set("text", me.formatDuration(seek));
|
||
|
return me.timer = setTimeout((function() {
|
||
|
return func();
|
||
|
}), 1000);
|
||
|
}
|
||
|
};
|
||
|
return func();
|
||
|
} else {
|
||
|
me.totaltime.set("text", "--:--");
|
||
|
me.progress.set("value", me.progress.get("max"));
|
||
|
func = function() {
|
||
|
var seek;
|
||
|
if (sound.playing()) {
|
||
|
seek = Math.round(sound.seek()) || 0;
|
||
|
me.playtime.set("text", me.formatDuration(seek));
|
||
|
return me.timer = setTimeout((function() {
|
||
|
return func();
|
||
|
}), 1000);
|
||
|
}
|
||
|
};
|
||
|
return func();
|
||
|
}
|
||
|
},
|
||
|
onload: function() {
|
||
|
// Start the wave animation.
|
||
|
console.log("load");
|
||
|
$(me.animator).css("visibility", "hidden");
|
||
|
if (!file.broadcast) {
|
||
|
return sound.play();
|
||
|
}
|
||
|
},
|
||
|
onend: function() {
|
||
|
// Stop the wave animation.
|
||
|
me.progress.set("value", 0);
|
||
|
if (me.timer) {
|
||
|
clearTimeout(me.timer);
|
||
|
}
|
||
|
me.playpause.set("swon", false);
|
||
|
$(me.animator).css("visibility", "hidden");
|
||
|
return me.nextSong();
|
||
|
},
|
||
|
onpause: function() {
|
||
|
// Stop the wave animation.
|
||
|
console.log("pause");
|
||
|
if (me.timer) {
|
||
|
clearTimeout(me.timer);
|
||
|
}
|
||
|
me.playpause.set("swon", false);
|
||
|
return $(me.animator).css("visibility", "hidden");
|
||
|
},
|
||
|
onstop: function() {
|
||
|
me.progress.set("value", 0);
|
||
|
if (me.timer) {
|
||
|
clearTimeout(me.timer);
|
||
|
}
|
||
|
me.playpause.set("swon", false);
|
||
|
$(me.animator).css("visibility", "hidden");
|
||
|
return console.log("stop");
|
||
|
}
|
||
|
});
|
||
|
if (file.broadcast) {
|
||
|
sound.play();
|
||
|
}
|
||
|
} else {
|
||
|
sound.play();
|
||
|
}
|
||
|
return $(this.animator).css("visibility", "visible");
|
||
|
}
|
||
|
|
||
|
stop() {
|
||
|
if (this.currsong && this.currsong.howl) {
|
||
|
if (this.currsong.howl.playing()) {
|
||
|
return this.currsong.howl.stop();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
seek(v) {
|
||
|
var sound;
|
||
|
if (!(this.currsong && this.currsong.howl && !this.currsong.broadcast)) {
|
||
|
return;
|
||
|
}
|
||
|
if (!((this.progress.get("max")) > 0)) {
|
||
|
return;
|
||
|
}
|
||
|
sound = this.currsong.howl;
|
||
|
return sound.seek(v);
|
||
|
}
|
||
|
|
||
|
formatDuration(s) {
|
||
|
var min, sec;
|
||
|
min = Math.floor(s / 60);
|
||
|
sec = s % 60;
|
||
|
min = min < 10 ? `0${min}` : `${min}`;
|
||
|
sec = sec < 10 ? `0${sec}` : `${sec}`;
|
||
|
return `${min}:${sec}`;
|
||
|
}
|
||
|
|
||
|
cleanup(evt) {
|
||
|
return this.stop();
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
// only one instance is allow
|
||
|
MediaPlayer.singleton = true;
|
||
|
|
||
|
this.OS.register("MediaPlayer", MediaPlayer);
|
||
|
|
||
|
}).call(this);
|
||
|
|
||
|
/*! howler.js v2.0.9 | (c) 2013-2018, James Simpson of GoldFire Studios | MIT License | howlerjs.com */
|
||
|
!function(){"use strict";var e=function(){this.init()};e.prototype={init:function(){var e=this||n;return e._counter=1e3,e._codecs={},e._howls=[],e._muted=!1,e._volume=1,e._canPlayEvent="canplaythrough",e._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,e.masterGain=null,e.noAudio=!1,e.usingWebAudio=!0,e.autoSuspend=!0,e.ctx=null,e.mobileAutoEnable=!0,e._setup(),e},volume:function(e){var t=this||n;if(e=parseFloat(e),t.ctx||_(),void 0!==e&&e>=0&&e<=1){if(t._volume=e,t._muted)return t;t.usingWebAudio&&t.masterGain.gain.setValueAtTime(e,n.ctx.currentTime);for(var o=0;o<t._howls.length;o++)if(!t._howls[o]._webAudio)for(var r=t._howls[o]._getSoundIds(),a=0;a<r.length;a++){var u=t._howls[o]._soundById(r[a]);u&&u._node&&(u._node.volume=u._volume*e)}return t}return t._volume},mute:function(e){var t=this||n;t.ctx||_(),t._muted=e,t.usingWebAudio&&t.masterGain.gain.setValueAtTime(e?0:t._volume,n.ctx.currentTime);for(var o=0;o<t._howls.length;o++)if(!t._howls[o]._webAudio)for(var r=t._howls[o]._getSoundIds(),a=0;a<r.length;a++){var u=t._howls[o]._soundById(r[a]);u&&u._node&&(u._node.muted=!!e||u._muted)}return t},unload:function(){for(var e=this||n,t=e._howls.length-1;t>=0;t--)e._howls[t].unload();return e.usingWebAudio&&e.ctx&&void 0!==e.ctx.close&&(e.ctx.close(),e.ctx=null,_()),e},codecs:function(e){return(this||n)._codecs[e.replace(/^x-/,"")]},_setup:function(){var e=this||n;if(e.state=e.ctx?e.ctx.state||"running":"running",e._autoSuspend(),!e.usingWebAudio)if("undefined"!=typeof Audio)try{var t=new Audio;void 0===t.oncanplaythrough&&(e._canPlayEvent="canplay")}catch(n){e.noAudio=!0}else e.noAudio=!0;try{var t=new Audio;t.muted&&(e.noAudio=!0)}catch(e){}return e.noAudio||e._setupCodecs(),e},_setupCodecs:function(){var e=this||n,t=null;try{t="undefined"!=typeof Audio?new Audio:null}catch(n){return e}if(!t||"function"!=typeof t.canPlayType)return e;var o=t.canPlayType("audio/mpeg;").replace(/^no$/,""),r=e._navigator&&e._navigator.userAgent.match(/OPR\/([0-6].)/g),a=r&&parseInt(r[0].split("/")[1],10)<33;return e._codecs={mp3:!(a||!o&&!t.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!o,opus:!!t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!t.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),aac:!!t.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!t.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(t.canPlayType("audio/x-m4a;")||t.canPlayType("audio/m4a;")||t.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(t.canPlayType("audio/x-mp4;")||t.canPlayType("audio/mp4;")||t.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),webm:!!t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),dolby:!!t.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(t.canPlayType("audio/x-flac;")||t.canPlayType("audio/flac;")).replace(/^no$/,"")},e},_enableMobileAudio:function(){var e=this||n,t=/iPhone|iPad|iPod|Android|BlackBerry|BB10|Silk|Mobi/i.test(e._navigator&&e._navigator.userAgent),o=!!("ontouchend"in window||e._navigator&&e._navigator.maxTouchPoints>0||e._navigator&&e._navigator.msMaxTouchPoints>0);if(!e._mobileEnabled&&e.ctx&&(t||o)){e._mobileEnabled=!1,e._mobileUnloaded||44100===e.ctx.sampleRate||(e._mobileUnloaded=!0,e.unload()),e._scratchBuffer=e.ctx.createBuffer(1,1,22050);var r=function(){n._autoResume();var t=e.ctx.createBufferSource();t.buffer=e._scratchBuffer,t.connect(e.ctx.destination),void 0===t.start?t.noteOn(0):t.start(0),"function"==typeof e.ctx.resume&&e.ctx.resume(),t.onended=function(){t.disconnect(0),e._mobileEnabled=!0,e.mobileAutoEnable=!1,document.removeEventListener("touchstart",r,!0),document.removeEventListener("touchend",r,!0)}};return document.addEventListener("touchstart",r,!0),document.addEventListener("touchend",r,!0),e}},_autoSuspend:function(){var e=this;if(e.autoSuspend&&e.ctx&&void 0!==e.ctx.suspend&&n.usingWebAudio){for(var t
|
||
|
/*! Spatial Plugin */
|
||
|
!function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(n){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var t=e._howls.length-1;t>=0;t--)e._howls[t].stereo(n);return e},HowlerGlobal.prototype.pos=function(n,e,t){var o=this;return o.ctx&&o.ctx.listener?(e="number"!=typeof e?o._pos[1]:e,t="number"!=typeof t?o._pos[2]:t,"number"!=typeof n?o._pos:(o._pos=[n,e,t],o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]),o)):o},HowlerGlobal.prototype.orientation=function(n,e,t,o,r,a){var i=this;if(!i.ctx||!i.ctx.listener)return i;var p=i._orientation;return e="number"!=typeof e?p[1]:e,t="number"!=typeof t?p[2]:t,o="number"!=typeof o?p[3]:o,r="number"!=typeof r?p[4]:r,a="number"!=typeof a?p[5]:a,"number"!=typeof n?p:(i._orientation=[n,e,t,o,r,a],i.ctx.listener.setOrientation(n,e,t,o,r,a),i)},Howl.prototype.init=function(n){return function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._pannerAttr={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:360,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:360,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:0,distanceModel:void 0!==e.distanceModel?e.distanceModel:"inverse",maxDistance:void 0!==e.maxDistance?e.maxDistance:1e4,panningModel:void 0!==e.panningModel?e.panningModel:"HRTF",refDistance:void 0!==e.refDistance?e.refDistance:1,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:1},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],n.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(e,t){var o=this;if(!o._webAudio)return o;if("loaded"!==o._state)return o._queue.push({event:"stereo",action:function(){o.stereo(e,t)}}),o;var r=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===t){if("number"!=typeof e)return o._stereo;o._stereo=e,o._pos=[e,0,0]}for(var a=o._getSoundIds(t),i=0;i<a.length;i++){var p=o._soundById(a[i]);if(p){if("number"!=typeof e)return p._stereo;p._stereo=e,p._pos=[e,0,0],p._node&&(p._pannerAttr.panningModel="equalpower",p._panner&&p._panner.pan||n(p,r),"spatial"===r?p._panner.setPosition(e,0,0):p._panner.pan.setValueAtTime(e,Howler.ctx.currentTime)),o._emit("stereo",p._id)}}return o},Howl.prototype.pos=function(e,t,o,r){var a=this;if(!a._webAudio)return a;if("loaded"!==a._state)return a._queue.push({event:"pos",action:function(){a.pos(e,t,o,r)}}),a;if(t="number"!=typeof t?0:t,o="number"!=typeof o?-.5:o,void 0===r){if("number"!=typeof e)return a._pos;a._pos=[e,t,o]}for(var i=a._getSoundIds(r),p=0;p<i.length;p++){var s=a._soundById(i[p]);if(s){if("number"!=typeof e)return s._pos;s._pos=[e,t,o],s._node&&(s._panner&&!s._panner.pan||n(s,"spatial"),s._panner.setPosition(e,t,o)),a._emit("pos",s._id)}}return a},Howl.prototype.orientation=function(e,t,o,r){var a=this;if(!a._webAudio)return a;if("loaded"!==a._state)return a._queue.push({event:"orientation",action:function(){a.orientation(e,t,o,r)}}),a;if(t="number"!=typeof t?a._orientation[1]:t,o="number"!=typeof o?a._orientation[2]:o,void 0===r){if("number"!=typeof e)return a._orientation;a._orientation=[e,t,o]}for(var i=a._getSoundIds(r),p=0;p<i.length;p++){var s=a._soundById(i[p]);if(s){if("number"!=typeof e)return s._orientation;s._orientation=[e,t,o],s._node&&(s._panner||(s._pos||(s._pos=a._pos||[0,0,-.5]),n(s,"spatial")),s._panner.setOrientation(e,t,o)),a._emit("orientation",s._id)}}return a},Howl.prototype.pannerAttr=function(){var e,t,o,r=this,a=arguments;if(!r._webAudio)return r;if(0===a.length)return r._pannerAttr;if(1===a.length){if("object"!=typeof a[0])return o=r._soundById(parseInt(a[0],10)),o?o._pannerAttr:r._pannerAttr;e=a[0],void 0===t&&(e.pannerAttr||(e.pannerAttr={coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}),r._panner
|