Compare commits

...

65 Commits

Author SHA1 Message Date
Anirudh Sevugan
a26e1448ab
Update renderer.js
Some checks failed
Build Linux / build_x64 (push) Has been cancelled
Build Linux / build_arm64 (push) Has been cancelled
Build macOS / build (push) Has been cancelled
Build Windows / build-x64 (push) Has been cancelled
Build Windows / build-arm64 (push) Has been cancelled
2025-09-15 18:19:03 -05:00
Anirudh Sevugan
59a8d5c577
v2.1.4 2025-09-15 18:17:27 -05:00
Anirudh Sevugan
ef5e34331e
Update main.js
Some checks are pending
Build Linux / build_x64 (push) Waiting to run
Build Linux / build_arm64 (push) Waiting to run
Build macOS / build (push) Waiting to run
Build Windows / build-x64 (push) Waiting to run
Build Windows / build-arm64 (push) Waiting to run
2025-09-14 22:35:14 -05:00
Anirudh Sevugan
cc5da53f23
Update package-arm64-linux.json 2025-09-14 22:35:06 -05:00
Anirudh Sevugan
5d0128e2af
Update package.json 2025-09-14 22:34:56 -05:00
Anirudh Sevugan
101f14c4d6
Update package.json 2025-09-14 22:34:49 -05:00
Anirudh Sevugan
49939dd963
Update package-arm64-linux.json 2025-09-14 22:34:30 -05:00
Anirudh Sevugan
257218c5a1
prep for 2.1.4
Some checks failed
Build Windows / build-x64 (push) Has been cancelled
Build Windows / build-arm64 (push) Has been cancelled
Build macOS / build (push) Has been cancelled
Build Linux / build_x64 (push) Has been cancelled
Build Linux / build_arm64 (push) Has been cancelled
2025-09-10 21:38:47 -05:00
Anirudh Sevugan
808c275167
prep for 2.1.4 2025-09-10 21:37:38 -05:00
Anirudh Sevugan
5d49c97662
v2.1.3 2025-09-10 21:09:15 -05:00
Anirudh Sevugan
16311d2eff
Update package-arm64-linux.json 2025-09-10 21:08:53 -05:00
Anirudh Sevugan
4a23d31b03
Update package.json 2025-09-10 21:08:39 -05:00
Anirudh Sevugan
97088fb943
Update main.js 2025-09-10 21:08:18 -05:00
Anirudh Sevugan
b987f539f8
Update player.js 2025-09-10 21:08:09 -05:00
Anirudh Sevugan
117d2950ea
Update renderer.js 2025-09-10 21:07:48 -05:00
Anirudh Sevugan
0aa0e06194
Update package.json 2025-09-10 21:07:33 -05:00
Anirudh Sevugan
2ddce17442
Update package-arm64-linux.json 2025-09-10 21:07:23 -05:00
Anirudh Sevugan
ae127fb837
v2.1.2
Some checks failed
Build Linux / build_x64 (push) Has been cancelled
Build Linux / build_arm64 (push) Has been cancelled
Build macOS / build (push) Has been cancelled
Build Windows / build-x64 (push) Has been cancelled
Build Windows / build-arm64 (push) Has been cancelled
2025-09-04 17:22:32 -05:00
Anirudh Sevugan
f7fa4bf081
Update package-arm64-linux.json
Some checks are pending
Build Linux / build_x64 (push) Waiting to run
Build Linux / build_arm64 (push) Waiting to run
Build macOS / build (push) Waiting to run
Build Windows / build-x64 (push) Waiting to run
Build Windows / build-arm64 (push) Waiting to run
2025-09-03 22:45:33 -05:00
Anirudh Sevugan
9cdbc5e328
Update package-arm64-linux.json 2025-09-03 22:45:23 -05:00
Anirudh Sevugan
778cc0ec74
Update package.json 2025-09-03 22:45:11 -05:00
Anirudh Sevugan
451313f414
Update package.json 2025-09-03 22:45:02 -05:00
Anirudh Sevugan
2c6b048721
Update main-es.js 2025-09-03 22:44:50 -05:00
Anirudh Sevugan
adb0647fdc
Update main.js 2025-09-03 22:42:17 -05:00
Anirudh Sevugan
f06f2cc9fc
Update README.md 2025-09-01 19:33:25 -05:00
Anirudh Sevugan
8fd5de8b75
Update package.json 2025-08-31 14:53:48 -05:00
Anirudh Sevugan
20f5d7e250
Update package.json 2025-08-31 14:49:57 -05:00
Anirudh Sevugan
6125553e40
Update player.js 2025-08-29 19:43:45 -05:00
Anirudh Sevugan
ec3332a248
Update README.txt 2025-08-28 20:47:05 -05:00
Anirudh Sevugan
7a7cb4d8fd
use executableName
use executableName only when it is available in electron-builder stable
2025-08-28 17:55:49 -05:00
Anirudh Sevugan
a815b4c431
use executableName when in stable
use executableName only when it is available in electron-builder stable
2025-08-28 17:55:30 -05:00
Anirudh Sevugan
f20c520123
2.1.1
changes: fixed `Exec` field missing from .desktop file in Snap, and upgraded Electron to 37.4.0 (only upgraded because of fixing `Exec` field missing from .desktop file in Snap)
2025-08-28 17:48:52 -05:00
Anirudh Sevugan
4675073530
Update main.js 2025-08-28 17:47:54 -05:00
Anirudh Sevugan
ad979d6b86
Update package.json 2025-08-28 17:47:46 -05:00
Anirudh Sevugan
1abe50b40a
Update package-arm64-linux.json 2025-08-28 17:47:32 -05:00
Anirudh Sevugan
d03513ea3d
Update package-arm64-linux.json 2025-08-28 17:44:13 -05:00
Anirudh Sevugan
2560bd4315
Update package.json 2025-08-28 17:43:58 -05:00
Anirudh Sevugan
99303f82e7
2.1.0
fixes memory leak issues and unnecessary Blob URL usage for subtitles along with improving the versioning system
2025-08-24 16:42:54 -05:00
Anirudh Sevugan
1d38e90b2b
Update package-arm64-linux.json 2025-08-24 16:41:56 -05:00
Anirudh Sevugan
0513fa7b23
Update package.json 2025-08-24 16:41:46 -05:00
Anirudh Sevugan
fde5bc7fe2
Update main.js 2025-08-24 16:41:36 -05:00
Anirudh Sevugan
6e4f9d0459
Update player.js 2025-08-24 16:40:21 -05:00
Anirudh Sevugan
2176853993
add support for SRT subtitles 2025-08-22 15:44:23 -05:00
Anirudh Sevugan
32645bb3cf
Update main-es.js 2025-08-22 15:43:18 -05:00
Anirudh Sevugan
47f7753b99
Update main.js 2025-08-22 15:43:09 -05:00
Anirudh Sevugan
6a0d9cb53a
Update package.json 2025-08-22 15:42:57 -05:00
Anirudh Sevugan
97c7b4d4dd
Update package-arm64-linux.json 2025-08-22 15:42:46 -05:00
Anirudh Sevugan
095d9fcfc2
Update main-es.js 2025-08-19 17:43:57 -05:00
Anirudh Sevugan
f2e43a55f9
Update main.js 2025-08-19 17:42:44 -05:00
Anirudh Sevugan
1c628866b6
Update main-es.js 2025-08-19 17:37:17 -05:00
Anirudh Sevugan
4995ea430c
Update main.js 2025-08-19 17:37:08 -05:00
Anirudh Sevugan
6df2e71cdb
Update package-arm64-linux.json 2025-08-19 17:36:54 -05:00
Anirudh Sevugan
b3409c56ab
Update package.json 2025-08-19 17:36:41 -05:00
Anirudh Sevugan
e617596a9b
Update README.md 2025-08-18 18:43:09 -05:00
Anirudh Sevugan
b903283b76
Update README.md 2025-08-18 18:42:54 -05:00
Anirudh Sevugan
4b167af46f
Update README.md 2025-08-18 18:42:18 -05:00
Anirudh Sevugan
d396ceefed
Update README.md 2025-08-18 18:36:48 -05:00
Anirudh Sevugan
db55349be9
Update README.md 2025-08-18 18:36:28 -05:00
Anirudh Sevugan
32563f1491
Update README.md 2025-08-18 18:36:10 -05:00
Anirudh Sevugan
1a6ba2ebad
Update main-es.js 2025-08-17 18:00:36 -05:00
Anirudh Sevugan
f7151dc9dd
Update main.js 2025-08-17 18:00:09 -05:00
Anirudh Sevugan
abcc95654c
Delete simpliplay/src directory 2025-08-17 17:59:35 -05:00
Anirudh Sevugan
2fa7daac19
Add files via upload 2025-08-17 17:58:49 -05:00
Anirudh Sevugan
9b1d81d28c
Update main.js 2025-08-17 17:58:34 -05:00
Anirudh Sevugan
f1f3a8ce24 fix bugs
Fix update system bug (2.0.4.3 instead of 2.0.4.4 as internal version number) and use Electron 37.3.0 for ARM64 Linux builds as well
2025-08-16 11:36:04 -05:00
9 changed files with 260 additions and 31 deletions

View File

@ -6,22 +6,25 @@ The desktop version of SimpliPlay, a simple, cross-platform media player.
## [simpliplay-lite](https://github.com/A-Star100/simpliplay-desktop/tree/lite) ## [simpliplay-lite](https://github.com/A-Star100/simpliplay-desktop/tree/lite)
[Neutralinojs](https://neutralino.js.org) version of SimpliPlay (significantly smaller filesize) for Windows (x64 only), macOS, and Linux (both x64 and ARM64). [Neutralinojs](https://neutralino.js.org) version of SimpliPlay (significantly smaller filesize) for Windows (x64 only), macOS, and Linux (both x64 and ARM64).
> [!WARNING]
> This version of SimpliPlay has been [officially discontinued](https://simpliplay.netlify.app/docs/blog/lite-ver-end) and **will not** receive any more security updates.
> It is still stable and secure, but has not received a few patches (e.g, the infamous **[memory leak issue](https://github.com/A-Star100/simpliplay-desktop/issues/4)**) that the web version, Chrome extension, and main desktop version all have.
## [simpliplay-nwjs](https://github.com/A-Star100/simpliplay-desktop/tree/nwjs) ## [simpliplay-nwjs](https://github.com/A-Star100/simpliplay-desktop/tree/nwjs)
[NW.js](https://nwjs.io) version of SimpliPlay for Windows, macOS, and Linux (x64 and ARM64). [NW.js](https://nwjs.io) version of SimpliPlay for Windows, macOS, and Linux (x64 and ARM64).
> [!WARNING] > [!IMPORTANT]
> This version is an example NW.js configuration, it won't be used in production, but you can use it if you would like. Files in this version won't be updated, so refer to files from the Electron release for production usage. > This version is an example NW.js configuration, it won't be used in production, but you can use it if you would like. Files in this version won't be updated, so refer to files from the Electron release for production usage.
## [simpliplay-legacy](https://github.com/A-Star100/simpliplay-desktop/tree/legacy) ## [simpliplay-legacy](https://github.com/A-Star100/simpliplay-desktop/tree/legacy)
[Legacy](https://simpliplay.netlify.app/legacy) version of SimpliPlay for Windows, macOS, and Linux (x64 and x86). [Legacy](https://simpliplay.netlify.app/legacy) version of SimpliPlay for Windows, macOS, and Linux (x64 and x86).
> [!WARNING] > [!CAUTION]
> This version uses a very old, legacy version of NW.js that supports Windows XP and macOS 10.6 or later. Unless the main desktop version isn't supported on your operating system, **don't** > This version uses a very old, legacy version of NW.js that supports Windows XP and macOS 10.6 or later.
> use the legacy version, it will open you up to security issues on newer devices! > Unless the main desktop version isn't supported on your operating system, **please don't use the legacy version**, it will open you up to **security issues** on newer devices!
___ ___
## Setup ## Setup
Read the docs ([Electron - Tutorial](https://www.electronjs.org/docs/latest/tutorial/tutorial-prerequisites), [Neutralinojs - Your First App](https://neutralino.js.org/docs/getting-started/your-first-neutralinojs-app), [NW.js - Getting Started (For Users)](https://nwjs.readthedocs.io/en/latest/For%20Users/Getting%20Started/#write-nwjs-app)) Read the docs ([Electron - Tutorial](https://www.electronjs.org/docs/latest/tutorial/tutorial-prerequisites), [Neutralinojs - Your First App](https://neutralino.js.org/docs/getting-started/your-first-neutralinojs-app), [NW.js - Getting Started (For Users)](https://nwjs.readthedocs.io/en/latest/For%20Users/Getting%20Started/#write-nwjs-app))
## Mirrors ## Mirrors
Self-hosted mirror available [here](https://git.anirudhsevugan.me/simpliplay/simpliplay-desktop-mirror). Self-hosted mirror available [here](https://new-git.anirudhsevugan.me/anirudh/simpliplay-desktop/src/branch/main/).
**The server may not always be up. You'll see a screen saying "Git is down" if the server is down, with a link to contact me (the webmaster)**. **The server may not always be up. If it isn't, you can contact me at: (personal at anirudhsevugan dot me)**.

View File

@ -1 +1,11 @@
Source code for SimpliPlay.
--BUILD STUFF--
SimpliPlay uses Electron Builder for desktop builds, but includes an example Electron Forge config that will work as expected but does not support native actions such as file picking from the explorer; the package.json uses electron-builder specific actions for that.
--CI/CD--
We now use CI/CD (specifically GitHub Actions, at one point CircleCI) for builds, but Linux ARM64 snaps in particular were annoying to get started with. After multiple attempts, it finally worked as expected (with a few really stupid workarounds required that shouldn't even be needed).
--DEPENDENCIES--
Other than Electron and Electron Builder, there is one more dependency called "Nothing".
Its name is very self explanatory, isn't it?

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@ -6,7 +6,7 @@ const { pathToFileURL } = require("url");
const { checkForUpdate } = require('./updateChecker'); const { checkForUpdate } = require('./updateChecker');
let gpuAccel = ""; let gpuAccel = "";
let didRegisterShortcuts = false; let didRegisterShortcuts = false;
let version = "2.0.4.3" let version = "2.1.3.0"
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
if (process.argv.includes('--use-gl')) { if (process.argv.includes('--use-gl')) {
@ -299,6 +299,27 @@ if (existingAddonsMenuItem) {
} }
})); }));
// "About Addons" menu item (info dialog version)
addonsMenu.append(new MenuItem({
label: 'Acerca de los complementos',
click: async () => {
const result = await dialog.showMessageBox(mainWindow, {
type: 'info',
buttons: ['De acuerdo'],
defaultId: 0,
title: 'Acerca de los complementos',
message: 'Los complementos pueden hacer casi cualquier cosa, desde añadir funciones al reproductor multimedia hasta añadir un juego completo dentro de la aplicación.',
detail: 'Los complementos son archivos JavaScript normales del lado del cliente con la extensión [.simpliplay].'
});
if (result.response === 0) {
console.log('El usuario hizo clic en Aceptar.');
// no need for dialog.closeDialog()
}
}
}));
// Add the Add-ons menu only once here: // Add the Add-ons menu only once here:
newMenuItems.push(new MenuItem({ label: 'Add-ons', submenu: addonsMenu })); newMenuItems.push(new MenuItem({ label: 'Add-ons', submenu: addonsMenu }));

View File

@ -6,7 +6,7 @@ const { pathToFileURL } = require("url");
const { checkForUpdate } = require('./updateChecker'); const { checkForUpdate } = require('./updateChecker');
let gpuAccel = ""; let gpuAccel = "";
let didRegisterShortcuts = false; let didRegisterShortcuts = false;
let version = "2.0.4.3" let version = "2.1.4.0"
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
if (process.argv.includes('--use-gl')) { if (process.argv.includes('--use-gl')) {
@ -285,6 +285,8 @@ if (existingAddonsMenuItem) {
} }
}); });
if (!addonsMenu.items.some(item => item.type === 'separator')) { if (!addonsMenu.items.some(item => item.type === 'separator')) {
addonsMenu.append(new MenuItem({ type: 'separator' })); addonsMenu.append(new MenuItem({ type: 'separator' }));
} }
@ -299,6 +301,34 @@ if (existingAddonsMenuItem) {
} }
})); }));
// "About Addons" menu item (info dialog version)
addonsMenu.append(new MenuItem({
label: 'About Addons',
click: async () => {
const result = await dialog.showMessageBox(mainWindow, {
type: 'info',
buttons: ['OK'],
defaultId: 0,
title: 'About Addons',
message: 'Addons can do almost anything from adding features to the media player to adding an entire game within the app!',
detail: 'Addons are regular, client-side JavaScript files with the [.simpliplay] extension.'
});
if (result.response === 0) {
console.log('User clicked OK');
// no need for dialog.closeDialog()
}
}
}));
// "Store" menu item (info dialog version)
addonsMenu.append(new MenuItem({
label: 'Store',
click: () => {
shell.openExternal("https://simpliplay.netlify.app/addons/")
}
}));
// Add the Add-ons menu only once here: // Add the Add-ons menu only once here:
newMenuItems.push(new MenuItem({ label: 'Add-ons', submenu: addonsMenu })); newMenuItems.push(new MenuItem({ label: 'Add-ons', submenu: addonsMenu }));

View File

@ -1,6 +1,6 @@
{ {
"name": "SimpliPlay", "name": "SimpliPlay",
"version": "2.0.4", "version": "2.1.4",
"description": "SimpliPlay - The mission to make media playback accessible on every device, anywhere, anytime.", "description": "SimpliPlay - The mission to make media playback accessible on every device, anywhere, anytime.",
"main": "./main.js", "main": "./main.js",
"scripts": { "scripts": {
@ -92,6 +92,11 @@
"name": "FLAC Audio", "name": "FLAC Audio",
"role": "Viewer" "role": "Viewer"
}, },
{
"ext": "opus",
"name": "Opus Audio",
"role": "Viewer"
},
{ {
"ext": "mkv", "ext": "mkv",
"name": "MKV Video", "name": "MKV Video",
@ -113,7 +118,7 @@
"allowToChangeInstallationDirectory": true "allowToChangeInstallationDirectory": true
}, },
"devDependencies": { "devDependencies": {
"electron": "^37.2.5", "electron": "^38.1.0",
"electron-builder": "^26.0.12" "electron-builder": "^26.0.12"
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "SimpliPlay", "name": "SimpliPlay",
"version": "2.0.4", "version": "2.1.4",
"description": "The mission to make media playback accessible on every platform, anywhere, anytime.", "description": "The mission to make media playback accessible on every platform, anywhere, anytime.",
"main": "./main.js", "main": "./main.js",
"scripts": { "scripts": {
@ -23,6 +23,13 @@
"summary": "A cross-platform, simple media player.", "summary": "A cross-platform, simple media player.",
"description": "The mission to make media playback accessible on every platform, anywhere, anytime." "description": "The mission to make media playback accessible on every platform, anywhere, anytime."
}, },
"nsis": {
"oneClick": false,
"installerIcon": "icon.ico",
"uninstallerIcon": "icon.ico",
"uninstallDisplayName": "simpliplay-uninstaller",
"allowToChangeInstallationDirectory": true
},
"mac": { "mac": {
"target": [ "target": [
"dmg" "dmg"
@ -98,6 +105,11 @@
"name": "FLAC Audio", "name": "FLAC Audio",
"role": "Viewer" "role": "Viewer"
}, },
{
"ext": "opus",
"name": "Opus Audio",
"role": "Viewer"
},
{ {
"ext": "mkv", "ext": "mkv",
"name": "MKV Video", "name": "MKV Video",
@ -110,16 +122,8 @@
} }
] ]
}, },
"nsis": {
"oneClick": false,
"installerIcon": "icon.ico",
"uninstallerIcon": "icon.ico",
"uninstallDisplayName": "simpliplay-uninstaller",
"license": "LICENSE.md",
"allowToChangeInstallationDirectory": true
},
"devDependencies": { "devDependencies": {
"electron": "^37.3.0", "electron": "^38.1.0",
"electron-builder": "^26.0.12" "electron-builder": "^26.0.12"
} }
} }

View File

@ -65,36 +65,83 @@ document.addEventListener('DOMContentLoaded', () => {
} }
}); });
// Function to add subtitles dynamically (e.g., after URL input) async function addSubtitles(url) {
function addSubtitles(url) { // Remove existing tracks and revoke any previous blob URLs
// Remove any existing subtitle tracks
const existingTracks = mediaPlayer.getElementsByTagName('track'); const existingTracks = mediaPlayer.getElementsByTagName('track');
for (let track of existingTracks) { for (let i = existingTracks.length - 1; i >= 0; i--) {
const track = existingTracks[i];
if (track.src.startsWith('blob:')) URL.revokeObjectURL(track.src);
track.remove(); track.remove();
} }
// Create a new track for subtitles // Fetch subtitle content
let text = '';
try {
const res = await fetch(url);
text = await res.text();
} catch (err) {
console.error('Failed to fetch subtitles:', err);
return;
}
// Detect format
const firstLine = text.split(/\r?\n/)[0].trim();
const format = firstLine.startsWith('WEBVTT') || url.toLowerCase().endsWith('.vtt') ? 'vtt' : 'srt';
// Determine track source
let trackSrc = url;
if (format === 'srt') {
// Convert SRT → VTT
text = 'WEBVTT\n\n' + text
.replace(/\r+/g, '')
.replace(/^\s+|\s+$/g, '')
.split('\n')
.map(line => line.replace(/(\d+):(\d+):(\d+),(\d+)/g, '$1:$2:$3.$4'))
.join('\n');
// Create Blob URL for converted subtitles
const blob = new Blob([text], { type: 'text/vtt' });
trackSrc = URL.createObjectURL(blob);
}
// Create and append track
const track = document.createElement('track'); const track = document.createElement('track');
track.kind = 'subtitles'; track.kind = 'subtitles';
track.label = 'English'; track.label = 'English';
track.srclang = 'en'; track.srclang = 'en';
track.src = url; track.src = trackSrc;
track.default = true;
// Append the new track
mediaPlayer.appendChild(track); mediaPlayer.appendChild(track);
// Optionally, enable subtitles by default // Force enable immediately
track.track.mode = 'showing'; // Enable subtitles by default setTimeout(() => {
for (let t of mediaPlayer.textTracks) t.mode = 'disabled';
track.track.mode = 'showing';
}, 50);
} }
// Handle submit subtitle URL
/*// Handle submit subtitle URL
function clearSubtitles() { function clearSubtitles() {
const tracks = mediaPlayer.getElementsByTagName('track'); const tracks = mediaPlayer.getElementsByTagName('track');
for (let i = tracks.length - 1; i >= 0; i--) { for (let i = tracks.length - 1; i >= 0; i--) {
tracks[i].remove(); tracks[i].remove();
} }
}*/
function clearSubtitles() {
const tracks = mediaPlayer.getElementsByTagName('track');
for (let i = tracks.length - 1; i >= 0; i--) {
const track = tracks[i];
if (track.src.startsWith('blob:')) {
URL.revokeObjectURL(track.src); // free memory leaks from SRT to VTT converted subtitles
}
track.remove();
}
} }
// Use this function when a new video is loaded // Use this function when a new video is loaded
submitSubtitlesBtn.addEventListener('click', () => { submitSubtitlesBtn.addEventListener('click', () => {
@ -225,6 +272,7 @@ const { isHLS, isDASH } = await detectStreamType(url);
let previousObjectURL = null; // Store the last Object URL let previousObjectURL = null; // Store the last Object URL
window.objectURL = previousObjectURL
fileInput.addEventListener('change', (event) => { fileInput.addEventListener('change', (event) => {
if (hls !== null) { if (hls !== null) {
@ -245,8 +293,14 @@ const { isHLS, isDASH } = await detectStreamType(url);
// Revoke the previous Object URL if it exists // Revoke the previous Object URL if it exists
if (previousObjectURL) { if (previousObjectURL) {
URL.revokeObjectURL(previousObjectURL); URL.revokeObjectURL(previousObjectURL);
window.objectURL = previousObjectURL
} }
// Revoke previous file picker Object URL
if (window.previousDropURL) {
URL.revokeObjectURL(window.previousDropURL);
}
// Create a new Object URL for the selected file // Create a new Object URL for the selected file
const fileURL = URL.createObjectURL(file); const fileURL = URL.createObjectURL(file);
mediaPlayer.src = fileURL; mediaPlayer.src = fileURL;
@ -257,6 +311,7 @@ const { isHLS, isDASH } = await detectStreamType(url);
// Store the new Object URL for future cleanup // Store the new Object URL for future cleanup
previousObjectURL = fileURL; previousObjectURL = fileURL;
fileInput.value = "";
// Hide dialog after selecting a file // Hide dialog after selecting a file
dialogOverlay.style.display = 'none'; dialogOverlay.style.display = 'none';

View File

@ -16,6 +16,103 @@ function loadMedia(fileURL) {
} }
} }
window.addEventListener('DOMContentLoaded', () => {
const dropArea = document.createElement('div');
dropArea.style.position = 'fixed';
dropArea.style.top = '0';
dropArea.style.left = '0';
dropArea.style.width = '100vw';
dropArea.style.height = '100vh';
dropArea.style.display = 'none'; // hidden by default
dropArea.style.zIndex = '0'; // behind everything
dropArea.style.opacity = '0'; // invisible
document.body.appendChild(dropArea);
let dragCounter = 0; // track nested dragenter/dragleave events
window.addEventListener('dragenter', (e) => {
if (e.dataTransfer.types.includes('Files')) {
dragCounter++;
e.preventDefault();
e.stopPropagation();
}
});
window.addEventListener('dragleave', (e) => {
if (e.dataTransfer.types.includes('Files')) {
dragCounter--;
if (dragCounter <= 0) dragCounter = 0;
e.preventDefault();
e.stopPropagation();
}
});
window.addEventListener('dragover', (e) => {
if (e.dataTransfer.types.includes('Files')) {
e.preventDefault(); // allow drop
e.stopPropagation();
}
});
let previousDropURL = null; // Store last Object URL
window.previousDropURL = previousDropURL
window.addEventListener('drop', e => {
e.preventDefault();
e.stopPropagation();
const file = e.dataTransfer.files[0];
if (!file) return;
// Destroy existing HLS/DASH instances if they exist
if (window.hls) {
window.hls.destroy();
window.hls = null;
}
if (window.dash) {
window.dash.reset();
window.dash = null;
}
// Clear previously loaded subtitles
const tracks = mediaElement.getElementsByTagName('track');
for (let i = tracks.length - 1; i >= 0; i--) {
tracks[i].remove();
}
// Revoke previous Object URL
if (previousDropURL) {
URL.revokeObjectURL(previousDropURL);
window.previousDropURL = previousDropURL;
}
// Revoke previous file picker Object URL
if (window.objectURL) {
URL.revokeObjectURL(window.objectURL);
}
// Create a new Object URL
const fileURL = URL.createObjectURL(file);
mediaElement.src = fileURL;
mediaElement.load();
// Autoplay if checkbox is checked
if (autoplayCheckbox.checked) {
mediaElement.play().catch(err => console.warn(err));
}
// Store for future cleanup
previousDropURL = fileURL;
// Hide file dialog if applicable
if (dialogOverlay) dialogOverlay.style.display = 'none';
});
});
// Handle submit subtitle URL // Handle submit subtitle URL
function clearSubtitles() { function clearSubtitles() {
const tracks = mediaElement.getElementsByTagName('track'); const tracks = mediaElement.getElementsByTagName('track');
@ -97,3 +194,7 @@ window.electron.receive("unload-addon", (fileURL) => {
unloadAddon(fileURL); unloadAddon(fileURL);
}); });