Update renderer.js

This commit is contained in:
Anirudh Sevugan 2025-02-23 16:00:50 +05:30 committed by GitHub
parent fffd3b6b6f
commit ebd275fb81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,15 +3,18 @@ window.electron.receive("play-media", (filePath) => {
loadMedia(filePath);
});
// Function to load and play media file
function loadMedia(filePath) {
dialogOverlay.style.display = 'none';
const mediaElement = document.getElementById("mediaPlayer");
if (mediaElement) {
mediaElement.src = `file://${filePath}`; // ✅ Convert file path to a valid URL
// Encode special characters in the file path
const encodedFilePath = encodeURI(`file://${filePath}`);
mediaElement.src = encodedFilePath; // ✅ Use encoded file path
if (autoplayCheckbox && autoplayCheckbox.checked) {
mediaElement.play();
}
}
}