Paste your HLS (.m3u8) URL below to instantly preview the stream and generate the embed code for your Blogger site.
2. Live Preview
Video preview will load here upon input.
`.trim();
embedCodeOutput.value = embedHtml;
// Also run the preview instantly
initHls(hlsUrl, previewVideo);
}
/**
* Utility function to copy text to clipboard and show a temporary notification.
*/
function copyToClipboard(elementId) {
const copyText = document.getElementById(elementId);
copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices
try {
// document.execCommand('copy') is generally more reliable in iFrames/sandbox environments
document.execCommand('copy');
const notification = document.getElementById('copyNotification');
notification.textContent = 'Successfully copied to clipboard!';
notification.classList.remove('opacity-0');
notification.classList.add('opacity-100');
setTimeout(() => {
notification.classList.remove('opacity-100');
notification.classList.add('opacity-0');
}, 2000);
} catch (err) {
console.error('Could not copy text: ', err);
alert('Copying failed! Please manually select and copy the code.');
}
}
// Initialize with a placeholder URL on load for demonstration
window.onload = () => {
const defaultUrl = 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8';
hlsUrlInput.value = defaultUrl;
handleUrlInput(defaultUrl);
generateEmbedCode();
};