diff --git a/materialious/package-lock.json b/materialious/package-lock.json index ade68fa3..2d321619 100644 --- a/materialious/package-lock.json +++ b/materialious/package-lock.json @@ -1,12 +1,12 @@ { "name": "materialious", - "version": "1.16.1", + "version": "1.16.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "materialious", - "version": "1.16.1", + "version": "1.16.2", "hasInstallScript": true, "dependencies": { "@capacitor-community/electron": "^5.0.1", @@ -21,6 +21,7 @@ "@capacitor/share": "^8.0.0", "@macfja/serializer": "^1.1.4", "@macfja/svelte-persistent-store": "^2.4.2", + "@neodrag/svelte": "^3.0.0-next.8", "altcha": "^2.3.0", "altcha-lib": "^1.4.1", "beercss": "^4.0.2", @@ -3523,6 +3524,23 @@ "node": ">= 10" } }, + "node_modules/@neodrag/core": { + "version": "3.0.0-next.8", + "resolved": "https://registry.npmjs.org/@neodrag/core/-/core-3.0.0-next.8.tgz", + "integrity": "sha512-RNFwbo2w6M7BEzCh7pls68X2h3n+ofFDW1XnGyIzhtJ2bb8J/2VqixOpOlw9NfSJ61xgUC5ymGQbQFg5BKsWBA==", + "license": "MIT", + "peer": true + }, + "node_modules/@neodrag/svelte": { + "version": "3.0.0-next.8", + "resolved": "https://registry.npmjs.org/@neodrag/svelte/-/svelte-3.0.0-next.8.tgz", + "integrity": "sha512-VkTnOqiHpAaEK5jp2PqQPEEx5AaNGVoKeoC2TuWd2xuteGOVq7NqQjNC4sxk0HAVysfYOC9YhYOsVyRiKo2LFw==", + "license": "MIT", + "peerDependencies": { + "@neodrag/core": "3.0.0-next.8", + "svelte": "^3 || ^4 || ^5" + } + }, "node_modules/@noble/hashes": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", diff --git a/materialious/package.json b/materialious/package.json index b8072d4b..3cb841f1 100644 --- a/materialious/package.json +++ b/materialious/package.json @@ -57,6 +57,7 @@ "@capacitor/share": "^8.0.0", "@macfja/serializer": "^1.1.4", "@macfja/svelte-persistent-store": "^2.4.2", + "@neodrag/svelte": "^3.0.0-next.8", "altcha": "^2.3.0", "altcha-lib": "^1.4.1", "beercss": "^4.0.2", @@ -96,4 +97,4 @@ "youtubei.js": "^16.0.1", "zod": "^4.3.6" } -} \ No newline at end of file +} diff --git a/materialious/src/lib/components/player/ClosedCaptions.svelte b/materialious/src/lib/components/player/ClosedCaptions.svelte new file mode 100644 index 00000000..8e7cad3d --- /dev/null +++ b/materialious/src/lib/components/player/ClosedCaptions.svelte @@ -0,0 +1,135 @@ + + + + +{#if trackVisible && captionsCues.length > 0} + {@const currentCaption = findElementForTime( + captionsCues, + currentTime, + (cue: VTTCue) => cue.startTime, + (cue: VTTCue) => cue.endTime + )} +
[ + bounds(BoundsFrom.element(playerContainer)), + touchAction('manipulation') + ])} + style="z-index: 5;cursor: grab;" + > + {#if currentCaption?.text} +

+ {removeTags(currentCaption.text)} +

+ {/if} +
+{/if} diff --git a/materialious/src/lib/components/player/Player.svelte b/materialious/src/lib/components/player/Player.svelte index 0b43535f..a096e2b9 100644 --- a/materialious/src/lib/components/player/Player.svelte +++ b/materialious/src/lib/components/player/Player.svelte @@ -65,6 +65,7 @@ import TouchControls from './TouchControls.svelte'; import { Network, type ConnectionStatus } from '@capacitor/network'; import { ScreenOrientation, type ScreenOrientationResult } from '@capacitor/screen-orientation'; + import ClosedCaptions from './ClosedCaptions.svelte'; interface Props { data: { video: VideoPlay; content: ParsedDescription; playlistId: string | null }; @@ -286,28 +287,6 @@ await player.load(dashUrl, await getLastPlayPos()); } - if (data.video.captions) { - for (const caption of data.video.captions) { - let captionUrl: string; - if (!getPublicEnv('DEFAULT_COMPANION_INSTANCE') && $invidiousInstanceStore) { - captionUrl = caption.url.startsWith('http') - ? caption.url - : `${new URL($invidiousInstanceStore).origin}${caption.url}`; - } else { - captionUrl = `${getPublicEnv('DEFAULT_COMPANION_INSTANCE')}${caption.url}`; - } - - await player.addTextTrackAsync( - captionUrl, - caption.language_code, - 'captions', - undefined, - undefined, - caption.label - ); - } - } - if (data.content.timestamps) { try { player.addChaptersTrack( @@ -894,6 +873,8 @@ }} bind:this={playerContainer} > + +