fix: copy stream url bug (#69)
This commit is contained in:
@@ -476,20 +476,30 @@ class VideoPlayer {
|
||||
streamUrl = window.location.origin + streamUrl;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(streamUrl).then(() => {
|
||||
// Show brief feedback
|
||||
const btn = document.getElementById('btn-copy-url');
|
||||
if (btn) {
|
||||
const originalText = btn.textContent;
|
||||
btn.textContent = '✓ Copied!';
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
|
||||
}, 1500);
|
||||
}
|
||||
console.log('[Player] Stream URL copied:', streamUrl);
|
||||
}).catch(() => {
|
||||
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(() => {
|
||||
// Show brief feedback
|
||||
const btn = document.getElementById('btn-copy-url');
|
||||
if (btn) {
|
||||
const originalText = btn.textContent;
|
||||
btn.textContent = '✓ Copied!';
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
|
||||
}, 1500);
|
||||
}
|
||||
console.log('[Player] Stream URL copied:', streamUrl);
|
||||
}).catch(() => {
|
||||
showPromptFallback();
|
||||
});
|
||||
} else {
|
||||
// Fallback for insecure contexts (HTTP)
|
||||
showPromptFallback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -740,19 +740,29 @@ class WatchPage {
|
||||
streamUrl = window.location.origin + streamUrl;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(streamUrl).then(() => {
|
||||
// Show brief feedback
|
||||
const btn = document.getElementById('watch-copy-url');
|
||||
if (btn) {
|
||||
btn.textContent = '✓ Copied!';
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
|
||||
}, 1500);
|
||||
}
|
||||
console.log('[WatchPage] Stream URL copied:', streamUrl);
|
||||
}).catch(() => {
|
||||
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(() => {
|
||||
// Show brief feedback
|
||||
const btn = document.getElementById('watch-copy-url');
|
||||
if (btn) {
|
||||
btn.textContent = '✓ Copied!';
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
|
||||
}, 1500);
|
||||
}
|
||||
console.log('[WatchPage] Stream URL copied:', streamUrl);
|
||||
}).catch(() => {
|
||||
showPromptFallback();
|
||||
});
|
||||
} else {
|
||||
// Fallback for insecure contexts (HTTP)
|
||||
showPromptFallback();
|
||||
}
|
||||
}
|
||||
|
||||
// === UI Updates ===
|
||||
|
||||
Reference in New Issue
Block a user