App-MHFS
view release on metacpan or search on metacpan
share/public_html/static/music_worklet_inprogress/player/mhfsplayer.js view on Meta::CPAN
that._prev = async function() {
let prevtrack;
if(that.AudioQueue[0]) {
if(!that.AudioQueue[0].track.prev) return;
prevtrack = that.AudioQueue[0].track.prev;
}
else if(that.playlistCursor) {
if(!that.playlistCursor.prev) return;
prevtrack = that.playlistCursor.prev;
}
else {
return;
}
await that.StopQueue();
that.StopAudio();
that.StartQueue(prevtrack);
};
that._next = async function() {
let nexttrack;
if(that.AudioQueue[0]) {
if(!that.AudioQueue[0].track.next) return;
nexttrack = that.AudioQueue[0].track.next;
}
else if(that.playlistCursor) {
if(!that.playlistCursor.next) return;
nexttrack = that.playlistCursor.next;
}
else {
return;
}
await that.StopQueue();
that.StopAudio();
that.StartQueue(nexttrack);
};
that._seek = async function(time) {
let track;
if(that.AudioQueue[0]) {
track = that.AudioQueue[0].track;
}
else if(that.playlistCursor) {
track = that.playlistCursor;
}
else {
return;
}
const stime = Number(time);
console.log('SEEK ' + stime);
await that.StopQueue();
that.StopAudio();
that.StartQueue(track, stime);
};
that._pborderchanged = async function(pbstate) {
that.pborder = pbstate;
// we need either the last decoded but not queued track or the last track if everything is queued
let ti;
for(ti = 0; ;ti++) {
if(!that.AudioQueue[ti]) {
if(ti === 0) return;
ti--;
break;
}
if(!that.AudioQueue[ti].donedecode) return;
if(!that.AudioQueue[ti].queued) break;
}
// make ti our last track
that.AudioQueue.length = ti+1;
// determine the next track we want to queue
const track = getNextTrack(that.AudioQueue[ti].track);
await that.StopQueue();
// cancel cached decoded audio that's not apart of AQ
that.truncateDecoded();
if(!that.AudioQueue[ti]) {
console.log('no track');
}
// queue following the playback order
that.StartQueue(track);
};
// API
that.setVolume = function(val) {
that.GainNode.gain.setValueAtTime(val, that.ac.currentTime);
};
that.play = function() {
// resume audio
if(that.AudioQueue.length) {
that.ac.resume();
}
// start playback again
else if(that.playlistCursor) {
that.StartQueue(that.playlistCursor);
}
};
that.pause = function() {
that.ac.suspend();
};
that.isplaying = function() {
return (that.AudioQueue[0] && that.AudioQueue[0]._starttime && (that.ac.currentTime >= that.AudioQueue[0]._starttime) && (that.ac.currentTime <= that.AudioQueue[0].endTime));
};
that.tracktime = function() {
return that.AudioQueue[0] ? that.ac.currentTime-that.AudioQueue[0].starttime : 0;
};
that.queuetrack = async function(trackname) {
const unlock = await that.USERMUTEX.lock();
that._queuetracks([trackname]);
unlock();
};
that.playtrack = async function(trackname) {
const unlock = await that.USERMUTEX.lock();
await that._playtracks([trackname]);
unlock();
};
that.queuetracks = async function(tracknames) {
const unlock = await that.USERMUTEX.lock();
that._queuetracks(tracknames);
unlock();
};
that.playtracks = async function(tracknames) {
const unlock = await that.USERMUTEX.lock();
await that._playtracks(tracknames);
( run in 1.275 second using v1.01-cache-2.11-cpan-d7f47b0818f )