Initial support for offline playback

This commit is contained in:
Shiny Nematoda 2023-06-20 15:53:45 +00:00
parent 1372d87beb
commit 4353cacead
9 changed files with 116 additions and 50 deletions

View file

@ -60,6 +60,18 @@ async function Stream() {
}
});
window.offline = new shaka.offline.Storage(audioPlayer);
window.offline.configure({
offline: {
progressCallback: (data, prog) => console.log(data, prog),
trackSelectionCallback: tracks => [
tracks
.sort((a, b) => a.bandwidth - b.bandwidth)
.find(i => i.type == 'variant'),
],
},
});
audioPlayer.configure({
preferredAudioCodecs: codecs ? codecs.split(':') : ['opus', 'mp4a'],
manifest: {
@ -171,7 +183,7 @@ onMounted(() => {
if (data.state.urls.length > 2) {
const i = data.state.urls.findIndex(s => s.url == data.state.url);
data.getSong(data.state.urls[i - 1].url);
data.play(data.state.urls[i - 1]);
}
});
@ -179,7 +191,7 @@ onMounted(() => {
if (data.state.urls.length > 2) {
const i = data.state.urls.findIndex(s => s.url == data.state.url);
data.getSong(data.state.urls[i + 1].url);
data.play(data.state.urls[i + 1]);
}
});