-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (52 loc) · 1.95 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import db from './config/data.js';
import configurePlayer from './config/configure-player.js';
import loadSymbols from './config/load-symbols.js';
import observePlayer from './library/dom/observe-player.js';
import constructLiveRegion from './library/dom/construct-live-region.js';
import deployFragment from './library/dom/deploy-fragment.js';
import getTargetPlayerConfiguration from './library/dom/get-target-player-configuration.js';
import constructPlayerTemplate from './library/dom/construct-player-template.js';
import fetchAudioData from './library/fetch.js';
import initializePlayerInterface from './library/dom/initialize-player-interface.js';
import unlockWebkitAudioContext from './library/dsp/unlock-webkit-audio.js';
import processTargetBuffer from './library/buffer/process-target-buffer.js';
import updateUIReadyState from './library/buffer/update-ui-ready-state.js';
import setupAudioContext from './library/dsp/setup-audio-context.js';
import awaitFileStatus from './library/utilities/await-file-status.js';
class AudioPlayer {
constructor(args) {
this.db = db;
this.init(args);
}
init(args) {
configurePlayer(args);
loadSymbols();
observePlayer()
.then(() => {
constructLiveRegion();
deployFragment('message');
//original: fetch → await → build
db.status.playerConfig = getTargetPlayerConfiguration(db.status.viewportWidth);
constructPlayerTemplate(db.config.template);
try {
initializePlayerInterface();
updateUIReadyState('pending');
//start the main processing thread
fetchAudioData();
awaitFileStatus()
.then(() => {
unlockWebkitAudioContext();
setupAudioContext();
processTargetBuffer()
.then(() => {
updateUIReadyState('ready');
db.nodes.status[db.map.message].textContent = 'Audio Player Ready';
});
});
} catch (error) {
console.error('Error initializing interface:', error);
}
});
}
}
export default AudioPlayer;