mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-19 02:06:26 +00:00
Read shell capabilities by name
This commit is contained in:
parent
7917515d88
commit
e372da8fee
2 changed files with 8 additions and 3 deletions
1
src/common/Platform/shell/shell.d.ts
vendored
1
src/common/Platform/shell/shell.d.ts
vendored
|
|
@ -23,6 +23,7 @@ interface Shell {
|
|||
|
||||
type ShellCapabilities = {
|
||||
gpuVideoProcessing: boolean;
|
||||
nativeAssSubtitles: boolean;
|
||||
};
|
||||
|
||||
type ShellState = {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ const useShell = (): Shell => {
|
|||
});
|
||||
const [capabilities, setCapabilities] = useState<ShellCapabilities>({
|
||||
gpuVideoProcessing: false,
|
||||
nativeAssSubtitles: false,
|
||||
});
|
||||
|
||||
const on = (name: string, listener: (arg: any) => void) => events.on(name, listener);
|
||||
|
|
@ -91,15 +92,18 @@ const useShell = (): Shell => {
|
|||
|
||||
if (event.type === ShellEventType.INIT) {
|
||||
const { data } = event as ShellEventInit;
|
||||
const [, [,,, version], [,,, gpuVideoProcessing] = []] = data.transport.properties;
|
||||
const shellProperties = Object.fromEntries(data.transport.properties
|
||||
.filter((property) => property.length >= 4 && property[1])
|
||||
.map(([, name,, value]) => [name, value]));
|
||||
|
||||
setState((state) => ({
|
||||
...state,
|
||||
initialized: true,
|
||||
version,
|
||||
version: shellProperties.shellVersion ?? null,
|
||||
}));
|
||||
setCapabilities({
|
||||
gpuVideoProcessing: gpuVideoProcessing === 'true',
|
||||
gpuVideoProcessing: shellProperties.gpuVideoProcessing === 'true',
|
||||
nativeAssSubtitles: shellProperties.nativeAssSubtitles === 'true',
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue