simpliplay-desktop/simpliplay/renderer.js
2025-02-23 16:00:50 +05:30

21 lines
584 B
JavaScript

// Listen for media file path from main process
window.electron.receive("play-media", (filePath) => {
loadMedia(filePath);
});
function loadMedia(filePath) {
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 (autoplayCheckbox && autoplayCheckbox.checked) {
mediaElement.play();
}
}
}