Compare commits
2 Commits
882d3404b9
...
cffb4ec9e2
| Author | SHA1 | Date | |
|---|---|---|---|
| cffb4ec9e2 | |||
| 787f799ab1 |
@ -292,7 +292,7 @@ document.querySelectorAll('.play-file').forEach(link => {
|
|||||||
title: currentMusicFiles[currentMusicIndex].title,
|
title: currentMusicFiles[currentMusicIndex].title,
|
||||||
artist: folderName,
|
artist: folderName,
|
||||||
artwork: [
|
artwork: [
|
||||||
{ src: '/static/icons/logo-192x192.png', sizes: '192x192', type: 'image/png' }
|
{ src: '/icons/logo-192x192.png', sizes: '192x192', type: 'image/png' }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,20 +98,33 @@ audio.onended = function() {
|
|||||||
playerButton.innerHTML = playIcon;
|
playerButton.innerHTML = playIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
function downloadAudio() {
|
|
||||||
// Get the current audio source URL
|
|
||||||
const audioSrc = audio.currentSrc || audio.src;
|
async function downloadAudio() {
|
||||||
if (audioSrc) {
|
const src = audio.currentSrc;
|
||||||
// Create a temporary link element
|
if (!src) return;
|
||||||
|
|
||||||
|
// Fetch with credentials / correct mode
|
||||||
|
const response = await fetch(src, { credentials: 'same-origin' });
|
||||||
|
if (!response.ok) throw new Error(`Download failed: ${response.status}`);
|
||||||
|
|
||||||
|
// Grab the data as a Blob
|
||||||
|
const blob = await response.blob();
|
||||||
|
|
||||||
|
// Create your own blob: URL and anchor
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = audioSrc;
|
a.href = url;
|
||||||
// Extract the file name from the URL, decode it, and set as download attribute
|
|
||||||
let fileName = audioSrc.split('/').pop() || 'audio';
|
// Retain original filename if possible
|
||||||
fileName = decodeURIComponent(fileName);
|
let filename = decodeURIComponent(src.split('/').pop() || 'audio');
|
||||||
a.download = fileName;
|
a.download = filename;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
}
|
|
||||||
|
// Cleanup
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
const cacheName = 'gottesdienste-v1.2';
|
const cacheName = 'gottesdienste-v1.3';
|
||||||
const assets = [
|
const assets = [
|
||||||
'/',
|
'/',
|
||||||
'/static/app.css',
|
'/static/app.css',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user