mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-27 12:26:33 -08:00
Fix audio/video issues not playing on Linux (#1151)
This commit is contained in:
1 parent
1c867efe16
commit
4e3b489c63
6 files changed
+49
-18
No files matched your search
@@ -8,6 +8,7 @@ import { P, match } from 'ts-pattern';
|
||||
import { AutoboneErrorModal } from './AutoboneErrorModal';
|
||||
import { PlayCircleIcon } from '@/components/commons/icon/PlayIcon';
|
||||
import { useDebouncedEffect } from '@/hooks/timeout';
|
||||
import { AUTOBONE_VIDEO } from './StartRecording';
|
||||
|
||||
export function Recording({
|
||||
nextStep,
|
||||
@@ -165,7 +166,7 @@ export function Recording({
|
||||
<video
|
||||
preload="auto"
|
||||
ref={videoRef}
|
||||
src="/videos/autobone.webm"
|
||||
src={AUTOBONE_VIDEO}
|
||||
className="min-w-[12rem] w-[12rem]"
|
||||
muted
|
||||
loop
|
||||
|
||||
+4
-1
@@ -6,6 +6,9 @@ import { useLocalization } from '@fluent/react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { PlayCircleIcon } from '@/components/commons/icon/PlayIcon';
|
||||
import { useDebouncedEffect } from '@/hooks/timeout';
|
||||
import { fetchResourceUrl } from '@/utils/tauri';
|
||||
|
||||
export const AUTOBONE_VIDEO = await fetchResourceUrl('/videos/autobone.webm');
|
||||
|
||||
export function StartRecording({
|
||||
nextStep,
|
||||
@@ -98,7 +101,7 @@ export function StartRecording({
|
||||
<video
|
||||
preload="auto"
|
||||
ref={videoRef}
|
||||
src="/videos/autobone.webm"
|
||||
src={AUTOBONE_VIDEO}
|
||||
className="min-w-[12rem] w-[12rem]"
|
||||
muted
|
||||
loop
|
||||
|
||||
+27
-10
@@ -1,19 +1,36 @@
|
||||
import { fetchResourceUrl } from '@/utils/tauri';
|
||||
import { ResetType } from 'solarxr-protocol';
|
||||
|
||||
const quickResetStartedSound = new Audio(
|
||||
'/sounds/quick-reset-started-sound.mp3'
|
||||
await fetchResourceUrl('/sounds/quick-reset-started-sound.mp3')
|
||||
);
|
||||
const fullResetStartedSound = new Audio(
|
||||
await fetchResourceUrl('/sounds/full-reset-started-sound.mp3')
|
||||
);
|
||||
const fullResetStartedSound = new Audio('/sounds/full-reset-started-sound.mp3');
|
||||
const mountingResetStartedSound = new Audio(
|
||||
'/sounds/mounting-reset-started-sound.mp3'
|
||||
await fetchResourceUrl('/sounds/mounting-reset-started-sound.mp3')
|
||||
);
|
||||
const tapSetupSound1 = new Audio(
|
||||
await fetchResourceUrl('/sounds/first-tap.mp3')
|
||||
);
|
||||
const tapSetupSound2 = new Audio(
|
||||
await fetchResourceUrl('/sounds/second-tap.mp3')
|
||||
);
|
||||
const tapSetupSound3 = new Audio(
|
||||
await fetchResourceUrl('/sounds/third-tap.mp3')
|
||||
);
|
||||
const tapSetupSound4 = new Audio(
|
||||
await fetchResourceUrl('/sounds/fourth-tap.mp3')
|
||||
);
|
||||
const tapSetupSound5 = new Audio(
|
||||
await fetchResourceUrl('/sounds/fifth-tap.mp3')
|
||||
);
|
||||
const tapSetupSoundEnd = new Audio(
|
||||
await fetchResourceUrl('/sounds/end-tap.mp3')
|
||||
);
|
||||
const tapSetupExtraSound = new Audio(
|
||||
await fetchResourceUrl('/sounds/tapextrasetup.mp3')
|
||||
);
|
||||
const tapSetupSound1 = new Audio('/sounds/first-tap.mp3');
|
||||
const tapSetupSound2 = new Audio('/sounds/second-tap.mp3');
|
||||
const tapSetupSound3 = new Audio('/sounds/third-tap.mp3');
|
||||
const tapSetupSound4 = new Audio('/sounds/fourth-tap.mp3');
|
||||
const tapSetupSound5 = new Audio('/sounds/fifth-tap.mp3');
|
||||
const tapSetupSoundEnd = new Audio('/sounds/end-tap.mp3');
|
||||
const tapSetupExtraSound = new Audio('/sounds/tapextrasetup.mp3');
|
||||
|
||||
function restartAndPlay(audio: HTMLAudioElement, volume: number) {
|
||||
audio.volume = Math.min(1, Math.pow(volume, Math.E) + 0.05);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { isTauri } from '@tauri-apps/api/core';
|
||||
import { type } from '@tauri-apps/plugin-os';
|
||||
|
||||
/**
|
||||
* Fetches the resource as a blob if necessary because of https://github.com/tauri-apps/tauri/issues/3725
|
||||
* @param url static asset to fetch
|
||||
* @returns URL
|
||||
*/
|
||||
export async function fetchResourceUrl(url: string) {
|
||||
if (!isTauri() || type() !== 'linux') return url;
|
||||
return URL.createObjectURL(await fetch(url).then((res) => res.blob()));
|
||||
}
|
||||
+2
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"target": "es2022",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
@@ -17,9 +17,7 @@
|
||||
"jsx": "react-jsx",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
],
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src"],
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ export default defineConfig({
|
||||
},
|
||||
plugins: [react(), i18nHotReload(), visualizer() as PluginOption],
|
||||
build: {
|
||||
target: 'es2020',
|
||||
target: 'es2022',
|
||||
emptyOutDir: true,
|
||||
commonjsOptions: {
|
||||
include: [/solarxr-protocol/, /node_modules/],
|
||||
@@ -47,7 +47,7 @@ export default defineConfig({
|
||||
},
|
||||
optimizeDeps: {
|
||||
esbuildOptions: {
|
||||
target: 'es2020',
|
||||
target: 'es2022',
|
||||
},
|
||||
needsInterop: ['solarxr-protocol'],
|
||||
include: ['solarxr-protocol'],
|
||||
|
||||
Reference in new issue
Block a user