fix: copy stream url bug (#69)

This commit is contained in:
Technomancer702
2026-01-31 11:09:39 -08:00
parent 4e116d864b
commit 80d2c4bfb3
3 changed files with 47 additions and 27 deletions

2
package-lock.json generated
View File

@ -6,7 +6,7 @@
"packages": { "packages": {
"": { "": {
"name": "nodecast-tv", "name": "nodecast-tv",
"version": "2.0.0", "version": "2.1.4",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"dependencies": { "dependencies": {
"@ffprobe-installer/ffprobe": "^2.1.2", "@ffprobe-installer/ffprobe": "^2.1.2",

View File

@ -476,6 +476,12 @@ class VideoPlayer {
streamUrl = window.location.origin + streamUrl; streamUrl = window.location.origin + streamUrl;
} }
const showPromptFallback = () => {
prompt('Copy this URL:', streamUrl);
};
// navigator.clipboard is only available in secure contexts (HTTPS/localhost)
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(streamUrl).then(() => { navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback // Show brief feedback
const btn = document.getElementById('btn-copy-url'); const btn = document.getElementById('btn-copy-url');
@ -488,8 +494,12 @@ class VideoPlayer {
} }
console.log('[Player] Stream URL copied:', streamUrl); console.log('[Player] Stream URL copied:', streamUrl);
}).catch(() => { }).catch(() => {
prompt('Copy this URL:', streamUrl); showPromptFallback();
}); });
} else {
// Fallback for insecure contexts (HTTP)
showPromptFallback();
}
} }

View File

@ -740,6 +740,12 @@ class WatchPage {
streamUrl = window.location.origin + streamUrl; streamUrl = window.location.origin + streamUrl;
} }
const showPromptFallback = () => {
prompt('Copy this URL:', streamUrl);
};
// navigator.clipboard is only available in secure contexts (HTTPS/localhost)
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(streamUrl).then(() => { navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback // Show brief feedback
const btn = document.getElementById('watch-copy-url'); const btn = document.getElementById('watch-copy-url');
@ -751,8 +757,12 @@ class WatchPage {
} }
console.log('[WatchPage] Stream URL copied:', streamUrl); console.log('[WatchPage] Stream URL copied:', streamUrl);
}).catch(() => { }).catch(() => {
prompt('Copy this URL:', streamUrl); showPromptFallback();
}); });
} else {
// Fallback for insecure contexts (HTTP)
showPromptFallback();
}
} }
// === UI Updates === // === UI Updates ===