Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
443001a49b |
No files matched your search
@@ -1,15 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "webamp",
|
"name": "webamp",
|
||||||
"title": "Webamp",
|
"title": "Webamp",
|
||||||
"version": "0.1.1",
|
"version": "0.1.0",
|
||||||
"description": "A Winamp-style player on every Teahub page, fed by gandora.",
|
"description": "A Winamp-style player on every Teahub page, fed by gandora.",
|
||||||
"slots": {
|
"slots": {
|
||||||
"footer": "templates/custom/footer.tmpl"
|
"footer": "templates/custom/footer.tmpl"
|
||||||
},
|
},
|
||||||
"assets": ["public/assets/plugins/webamp/webamp-mod.js"],
|
"assets": ["public/assets/plugins/webamp/webamp-mod.js"],
|
||||||
"vendor": {
|
|
||||||
"public/assets/plugins/webamp/webamp.bundle.min.js": "https://registry.npmjs.org/webamp/-/webamp-1.5.0.tgz#package/built/webamp.bundle.min.js"
|
|
||||||
},
|
|
||||||
"config": {
|
"config": {
|
||||||
"playlist_url": "https://gandora.yolopreneur.lol/playlist.json"
|
"playlist_url": "https://gandora.yolopreneur.lol/playlist.json"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// teahub plugin: webamp — a Winamp-style player docked on every Teahub page.
|
// teahub plugin: webamp — a Winamp-style player docked on every Teahub page.
|
||||||
// Loads the self-hosted Webamp bundle on first click, so pages stay fast for everyone else.
|
// Loads Webamp from the CDN on first click, so pages stay fast for everyone else.
|
||||||
|
|
||||||
// Module scripts have no document.currentScript, so find our tag by its src.
|
// Module scripts have no document.currentScript, so find our tag by its data attribute.
|
||||||
const script = document.querySelector('script[src*="plugins/webamp/webamp-mod.js"]');
|
const script = document.querySelector('script[src*="plugins/webamp/webamp-mod.js"]');
|
||||||
const PLAYLIST_URL = script?.dataset.playlist;
|
const PLAYLIST_URL = script?.dataset.playlist;
|
||||||
const KEY = 'teahub-webamp-open';
|
const KEY = 'teahub-webamp-open';
|
||||||
@@ -36,20 +36,9 @@ async function loadTracks() {
|
|||||||
|
|
||||||
let webamp = null;
|
let webamp = null;
|
||||||
|
|
||||||
function loadWebamp() {
|
|
||||||
if (window.Webamp) return Promise.resolve(window.Webamp);
|
|
||||||
return new Promise((ok, fail) => {
|
|
||||||
const s = document.createElement('script');
|
|
||||||
s.src = new URL('webamp.bundle.min.js', import.meta.url).href;
|
|
||||||
s.onload = () => ok(window.Webamp);
|
|
||||||
s.onerror = fail;
|
|
||||||
document.head.appendChild(s);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function open() {
|
async function open() {
|
||||||
if (webamp) return;
|
if (webamp) return;
|
||||||
const Webamp = await loadWebamp();
|
const { default: Webamp } = await import('https://unpkg.com/webamp@1.5.0/built/webamp.bundle.min.mjs');
|
||||||
if (!Webamp.browserIsSupported()) return;
|
if (!Webamp.browserIsSupported()) return;
|
||||||
webamp = new Webamp({ initialTracks: await loadTracks() });
|
webamp = new Webamp({ initialTracks: await loadTracks() });
|
||||||
webamp.onClose(() => {
|
webamp.onClose(() => {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
{{/* teahub plugin: webamp */}}
|
{{/* teahub plugin: webamp */}}
|
||||||
<script type="module" nonce="{{ctx.CspScriptNonce}}" src="{{AssetUrlPrefix}}/plugins/webamp/webamp-mod.js?v=011" data-playlist="https://gandora.yolopreneur.lol/playlist.json"></script>
|
<script type="module" nonce="{{ctx.CspScriptNonce}}" src="{{AssetUrlPrefix}}/plugins/webamp/webamp-mod.js?v=010" data-playlist="https://gandora.yolopreneur.lol/playlist.json"></script>
|
||||||
Reference in new issue
Block a user