Improve MPV initialization and restore (#222)

- set mpv settings only after it has successfully started (at least on linux, settings were not taken)
- change timing of restore queue to behave properly
This commit is contained in:
Kendall Garner 2023-08-25 01:28:50 +00:00 committed by GitHub
parent b60ba27892
commit 1acfa93f1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

View file

@ -11,11 +11,6 @@
import { access, constants, readFile, writeFile } from 'fs';
import path, { join } from 'path';
import { deflate, inflate } from 'zlib';
import electronLocalShortcut from 'electron-localshortcut';
import log from 'electron-log';
import { autoUpdater } from 'electron-updater';
import uniq from 'lodash/uniq';
import MpvAPI from 'node-mpv';
import {
app,
BrowserWindow,
@ -27,6 +22,11 @@ import {
nativeImage,
BrowserWindowConstructorOptions,
} from 'electron';
import electronLocalShortcut from 'electron-localshortcut';
import log from 'electron-log';
import { autoUpdater } from 'electron-updater';
import uniq from 'lodash/uniq';
import MpvAPI from 'node-mpv';
import { disableMediaKeys, enableMediaKeys } from './features/core/player/media-keys';
import { store } from './features/core/settings/index';
import MenuBuilder from './menu';
@ -453,12 +453,15 @@ const createMpv = (data: { extraParameters?: string[]; properties?: Record<strin
params,
);
console.log('Setting MPV properties: ', properties);
mpv.setMultipleProperties(properties || {});
mpv.start().catch((error) => {
console.log('MPV failed to start', error);
});
// eslint-disable-next-line promise/catch-or-return
mpv.start()
.catch((error) => {
console.log('MPV failed to start', error);
})
.finally(() => {
console.log('Setting MPV properties: ', properties);
mpv.setMultipleProperties(properties || {});
});
mpv.on('status', (status, ...rest) => {
console.log('MPV Event: status', status.property, status.value, rest);