Remove XM suffix from XMPlayer calls
This commit is contained in:
parent
ce5fd027a3
commit
6a5fe5e024
3 changed files with 22 additions and 22 deletions
10
README.md
10
README.md
|
|
@ -9,13 +9,13 @@ FastTracker 2 .XM player, written for fun.
|
|||
There is an XM player and a visualizer which are separate components. The
|
||||
player API looks like this:
|
||||
|
||||
- `XMPlayer.initAudio` -> starts up audio context; it's available as
|
||||
- `XMPlayer.init` -> starts up audio context; it's available as
|
||||
`XMPlayer.audioctx`
|
||||
- `XMPlayer.loadXM(ArrayBuffer)` -> returns `true` if loaded, otherwise
|
||||
- `XMPlayer.load(ArrayBuffer)` -> returns `true` if loaded, otherwise
|
||||
barfs randomly
|
||||
- `XMPlayer.playXM()` -> starts playing
|
||||
- `XMPlayer.pauseXM()` -> obvious
|
||||
- `XMPlayer.stopXM()` -> obvious; call this before loading a new one
|
||||
- `XMPlayer.play()` -> starts playing
|
||||
- `XMPlayer.pause()` -> obvious
|
||||
- `XMPlayer.stop()` -> obvious; call this before loading a new one
|
||||
|
||||
Loading trackview.js is optional; without it, the player won't do any
|
||||
visualizations. Or, you can override the following to get callbacks:
|
||||
|
|
|
|||
12
shell.js
12
shell.js
|
|
@ -9,7 +9,7 @@ if (!window.XMView) {
|
|||
var XMView = window.XMView;
|
||||
|
||||
function loadXMAndInit(xmdata) {
|
||||
if (!XMPlayer.loadXM(xmdata)) {
|
||||
if (!XMPlayer.load(xmdata)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -19,10 +19,10 @@ function loadXMAndInit(xmdata) {
|
|||
playbutton.innerHTML='Play';
|
||||
playbutton.onclick = function() {
|
||||
if (XMPlayer.playing) {
|
||||
XMPlayer.pauseXM();
|
||||
XMPlayer.pause();
|
||||
playbutton.innerHTML='Play';
|
||||
} else {
|
||||
XMPlayer.playXM();
|
||||
XMPlayer.play();
|
||||
playbutton.innerHTML='Pause';
|
||||
}
|
||||
};
|
||||
|
|
@ -63,7 +63,7 @@ XMPlayer.handleDrop = function(e) {
|
|||
if (files.length < 1) return false;
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
XMPlayer.stopXM();
|
||||
XMPlayer.stop();
|
||||
loadXMAndInit(e.target.result);
|
||||
};
|
||||
reader.readAsArrayBuffer(files[0]);
|
||||
|
|
@ -78,7 +78,7 @@ function initFilelist() {
|
|||
a.href = '#'+entry[1];
|
||||
a.onclick = function() {
|
||||
el.style.display = "none";
|
||||
XMPlayer.stopXM();
|
||||
XMPlayer.stop();
|
||||
downloadXM(baseuri + entry[1]);
|
||||
};
|
||||
el.appendChild(a);
|
||||
|
|
@ -95,7 +95,7 @@ function initFilelist() {
|
|||
}
|
||||
|
||||
window.onload = function() {
|
||||
XMPlayer.initAudio();
|
||||
XMPlayer.init();
|
||||
initFilelist();
|
||||
|
||||
var uri = location.hash.substr(1);
|
||||
|
|
|
|||
22
xm.js
22
xm.js
|
|
@ -11,11 +11,11 @@ var XMView = window.XMView;
|
|||
|
||||
player.periodForNote = periodForNote;
|
||||
player.prettify_effect = prettify_effect;
|
||||
player.initAudio = initAudio;
|
||||
player.loadXM = loadXM;
|
||||
player.playXM = playXM;
|
||||
player.pauseXM = pauseXM;
|
||||
player.stopXM = stopXM;
|
||||
player.init = init;
|
||||
player.load = load;
|
||||
player.play = play;
|
||||
player.pause = pause;
|
||||
player.stop = stop;
|
||||
player.cur_songpos = -1;
|
||||
player.cur_pat = -1;
|
||||
player.cur_row = 64;
|
||||
|
|
@ -624,7 +624,7 @@ function UnrollSampleLoop(samp) {
|
|||
samp.type = 1;
|
||||
}
|
||||
|
||||
function loadXM(arrayBuf) {
|
||||
function load(arrayBuf) {
|
||||
var dv = new DataView(arrayBuf);
|
||||
player.xm = {};
|
||||
|
||||
|
|
@ -851,7 +851,7 @@ function loadXM(arrayBuf) {
|
|||
}
|
||||
|
||||
var jsNode, gainNode;
|
||||
function initAudio() {
|
||||
function init() {
|
||||
if (!player.audioctx) {
|
||||
var audioContext = window.AudioContext || window.webkitAudioContext;
|
||||
player.audioctx = new audioContext();
|
||||
|
|
@ -868,7 +868,7 @@ function initAudio() {
|
|||
}
|
||||
|
||||
player.playing = false;
|
||||
function playXM() {
|
||||
function play() {
|
||||
if (!player.playing) {
|
||||
// put paused events back into action, if any
|
||||
if (XMView.resume) XMView.resume();
|
||||
|
|
@ -891,7 +891,7 @@ function playXM() {
|
|||
player.playing = true;
|
||||
}
|
||||
|
||||
function pauseXM() {
|
||||
function pause() {
|
||||
if (player.playing) {
|
||||
jsNode.disconnect(gainNode);
|
||||
if (XMView.pause) XMView.pause();
|
||||
|
|
@ -899,7 +899,7 @@ function pauseXM() {
|
|||
player.playing = false;
|
||||
}
|
||||
|
||||
function stopXM() {
|
||||
function stop() {
|
||||
if (player.playing) {
|
||||
jsNode.disconnect(gainNode);
|
||||
player.playing = false;
|
||||
|
|
@ -909,6 +909,6 @@ function stopXM() {
|
|||
player.cur_songpos = -1;
|
||||
player.cur_ticksamp = 0;
|
||||
if (XMView.stop) XMView.stop();
|
||||
initAudio();
|
||||
init();
|
||||
}
|
||||
})(window);
|
||||
|
|
|
|||
Loading…
Reference in a new issue