Update renderer.js

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

View File

@ -1,20 +1,16 @@
// Listen for media file path from main process
window.electron.receive("play-media", (filePath) => {
loadMedia(filePath);
// Listen for media file URL from main process
window.electron.receive("play-media", (fileURL) => {
loadMedia(fileURL);
});
function loadMedia(filePath) {
function loadMedia(fileURL) {
dialogOverlay.style.display = 'none';
const mediaElement = document.getElementById("mediaPlayer");
if (mediaElement) {
// Encode special characters in the file path
const encodedFilePath = encodeURI(`file://${filePath}`);
mediaElement.src = encodedFilePath; // ✅ Use encoded file path
if (mediaElement) {
mediaElement.src = fileURL; // ✅ Safe, properly encoded URL
if (autoplayCheckbox && autoplayCheckbox.checked) {
mediaElement.play();
}
}
}