mpvVideoPlayer.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. /* eslint-disable indent */
  2. function getMediaStreamAudioTracks(mediaSource) {
  3. return mediaSource.MediaStreams.filter(function (s) {
  4. return s.Type === 'Audio';
  5. });
  6. }
  7. class mpvVideoPlayer {
  8. constructor({ events, loading, appRouter, globalize, appHost, appSettings, confirm, dashboard }) {
  9. this.events = events;
  10. this.loading = loading;
  11. this.appRouter = appRouter;
  12. this.globalize = globalize;
  13. this.appHost = appHost;
  14. this.appSettings = appSettings;
  15. // this can be removed after 10.9
  16. this.setTransparency = (dashboard && dashboard.setBackdropTransparency)
  17. ? dashboard.setBackdropTransparency.bind(dashboard)
  18. : appRouter.setTransparency.bind(appRouter);
  19. /**
  20. * @type {string}
  21. */
  22. this.name = 'MPV Video Player';
  23. /**
  24. * @type {string}
  25. */
  26. this.type = 'mediaplayer';
  27. /**
  28. * @type {string}
  29. */
  30. this.id = 'mpvvideoplayer';
  31. this.syncPlayWrapAs = 'htmlvideoplayer';
  32. this.priority = -1;
  33. this.useFullSubtitleUrls = true;
  34. /**
  35. * @type {boolean}
  36. */
  37. this.isFetching = false;
  38. /**
  39. * @type {HTMLDivElement | null | undefined}
  40. */
  41. this._videoDialog = undefined;
  42. /**
  43. * @type {number | undefined}
  44. */
  45. this._subtitleTrackIndexToSetOnPlaying = undefined;
  46. /**
  47. * @type {number | null}
  48. */
  49. this._audioTrackIndexToSetOnPlaying = undefined;
  50. /**
  51. * @type {boolean | undefined}
  52. */
  53. this._showTrackOffset = undefined;
  54. /**
  55. * @type {number | undefined}
  56. */
  57. this._currentTrackOffset = undefined;
  58. /**
  59. * @type {string[] | undefined}
  60. */
  61. this._supportedFeatures = undefined;
  62. /**
  63. * @type {string | undefined}
  64. */
  65. this._currentSrc = undefined;
  66. /**
  67. * @type {boolean | undefined}
  68. */
  69. this._started = undefined;
  70. /**
  71. * @type {boolean | undefined}
  72. */
  73. this._timeUpdated = undefined;
  74. /**
  75. * @type {number | null | undefined}
  76. */
  77. this._currentTime = undefined;
  78. /**
  79. * @private (used in other files)
  80. * @type {any | undefined}
  81. */
  82. this._currentPlayOptions = undefined;
  83. /**
  84. * @type {any | undefined}
  85. */
  86. this._lastProfile = undefined;
  87. /**
  88. * @type {number | undefined}
  89. */
  90. this._duration = undefined;
  91. /**
  92. * @type {boolean}
  93. */
  94. this._paused = false;
  95. /**
  96. * @type {int}
  97. */
  98. this._volume = 100;
  99. /**
  100. * @type {boolean}
  101. */
  102. this._muted = false;
  103. /**
  104. * @type {float}
  105. */
  106. this._playRate;
  107. /**
  108. * @type {boolean}
  109. */
  110. this._hasConnection = false;
  111. /**
  112. * @private
  113. */
  114. this.onEnded = () => {
  115. this.onEndedInternal();
  116. };
  117. /**
  118. * @private
  119. */
  120. this.onTimeUpdate = (time) => {
  121. if (time && !this._timeUpdated) {
  122. this._timeUpdated = true;
  123. }
  124. this._currentTime = time;
  125. this.events.trigger(this, 'timeupdate');
  126. };
  127. /**
  128. * @private
  129. */
  130. this.onNavigatedToOsd = () => {
  131. const dlg = this._videoDialog;
  132. if (dlg) {
  133. dlg.style.zIndex = 'unset';
  134. }
  135. };
  136. /**
  137. * @private
  138. */
  139. this.onPlaying = () => {
  140. if (!this._started) {
  141. this._started = true;
  142. this.loading.hide();
  143. const volume = this.getSavedVolume() * 100;
  144. this.setVolume(volume, false);
  145. this.setPlaybackRate(this.getPlaybackRate());
  146. if (this._currentPlayOptions.fullscreen) {
  147. this.appRouter.showVideoOsd().then(this.onNavigatedToOsd);
  148. } else {
  149. this.setTransparency('backdrop');
  150. this._videoDialog.dlg.style.zIndex = 'unset';
  151. }
  152. // Need to override default style.
  153. this._videoDialog.style.setProperty('background', 'transparent', 'important');
  154. }
  155. if (this._paused) {
  156. this._paused = false;
  157. this.events.trigger(this, 'unpause');
  158. }
  159. this.events.trigger(this, 'playing');
  160. };
  161. /**
  162. * @private
  163. */
  164. this.onPause = () => {
  165. this._paused = true;
  166. // For Syncplay ready notification
  167. this.events.trigger(this, 'pause');
  168. };
  169. this.onWaiting = () => {
  170. this.events.trigger(this, 'waiting');
  171. };
  172. /**
  173. * @private
  174. * @param e {Event} The event received from the `<video>` element
  175. */
  176. this.onError = async (error) => {
  177. this.removeMediaDialog();
  178. console.error(`media error: ${error}`);
  179. const errorData = {
  180. type: 'mediadecodeerror'
  181. };
  182. try {
  183. await confirm({
  184. title: "Playback Failed",
  185. text: `Playback failed with error "${error}". Retry with transcode? (Note this may hang the player.)`,
  186. cancelText: "Cancel",
  187. confirmText: "Retry"
  188. });
  189. } catch (ex) {
  190. // User declined retry
  191. errorData.streamInfo = {
  192. // Prevent jellyfin-web retrying with transcode
  193. // which crashes the player
  194. mediaSource: {
  195. SupportsTranscoding: false
  196. }
  197. };
  198. }
  199. this.events.trigger(this, 'error', [errorData]);
  200. };
  201. this.onDuration = (duration) => {
  202. this._duration = duration;
  203. };
  204. }
  205. currentSrc() {
  206. return this._currentSrc;
  207. }
  208. async play(options) {
  209. this._started = false;
  210. this._timeUpdated = false;
  211. this._currentTime = null;
  212. this.resetSubtitleOffset();
  213. this.loading.show();
  214. window.api.power.setScreensaverEnabled(false);
  215. const elem = await this.createMediaElement(options);
  216. return await this.setCurrentSrc(elem, options);
  217. }
  218. getSavedVolume() {
  219. return this.appSettings.get('volume') || 1;
  220. }
  221. /**
  222. * @private
  223. */
  224. getRelativeIndexByType(mediaStreams, jellyIndex, streamType) {
  225. let relIndex = 1;
  226. for (const source of mediaStreams) {
  227. if (source.Type != streamType || source.IsExternal) {
  228. continue;
  229. }
  230. if (source.Index == jellyIndex) {
  231. return relIndex;
  232. }
  233. relIndex += 1;
  234. }
  235. return null;
  236. }
  237. /**
  238. * @private
  239. */
  240. getStreamByIndex(mediaStreams, jellyIndex) {
  241. for (const source of mediaStreams) {
  242. if (source.Index == jellyIndex) {
  243. return source;
  244. }
  245. }
  246. return null;
  247. }
  248. /**
  249. * @private
  250. */
  251. getSubtitleParam() {
  252. const options = this._currentPlayOptions;
  253. if (this._subtitleTrackIndexToSetOnPlaying != null && this._subtitleTrackIndexToSetOnPlaying >= 0) {
  254. const initialSubtitleStream = this.getStreamByIndex(options.mediaSource.MediaStreams, this._subtitleTrackIndexToSetOnPlaying);
  255. if (!initialSubtitleStream || initialSubtitleStream.DeliveryMethod === 'Encode') {
  256. this._subtitleTrackIndexToSetOnPlaying = -1;
  257. } else if (initialSubtitleStream.DeliveryMethod === 'External') {
  258. return '#,' + initialSubtitleStream.DeliveryUrl;
  259. }
  260. }
  261. if (this._subtitleTrackIndexToSetOnPlaying == -1 || this._subtitleTrackIndexToSetOnPlaying == null) {
  262. return '';
  263. }
  264. const subtitleRelIndex = this.getRelativeIndexByType(
  265. options.mediaSource.MediaStreams,
  266. this._subtitleTrackIndexToSetOnPlaying,
  267. 'Subtitle'
  268. );
  269. return subtitleRelIndex != null
  270. ? '#' + subtitleRelIndex
  271. : '';
  272. }
  273. /**
  274. * @private
  275. */
  276. getAudioParam() {
  277. const options = this._currentPlayOptions;
  278. if (this._audioTrackIndexToSetOnPlaying != null && this._audioTrackIndexToSetOnPlaying >= 0) {
  279. const initialAudioStream = this.getStreamByIndex(options.mediaSource.MediaStreams, this._audioTrackIndexToSetOnPlaying);
  280. if (!initialAudioStream) {
  281. return '#1';
  282. }
  283. }
  284. if (this._audioTrackIndexToSetOnPlaying == -1 || this._audioTrackIndexToSetOnPlaying == null) {
  285. return '#1';
  286. }
  287. const audioRelIndex = this.getRelativeIndexByType(
  288. options.mediaSource.MediaStreams,
  289. this._audioTrackIndexToSetOnPlaying,
  290. 'Audio'
  291. );
  292. return audioRelIndex != null
  293. ? '#' + audioRelIndex
  294. : '#1';
  295. }
  296. tryGetFramerate(options) {
  297. if (options.mediaSource && options.mediaSource.MediaStreams) {
  298. for (let stream of options.mediaSource.MediaStreams) {
  299. if (stream.Type == "Video") {
  300. return stream.RealFrameRate || stream.AverageFrameRate || null;
  301. }
  302. }
  303. }
  304. }
  305. /**
  306. * @private
  307. */
  308. setCurrentSrc(elem, options) {
  309. return new Promise((resolve) => {
  310. const val = options.url;
  311. this._currentSrc = val;
  312. console.debug(`playing url: ${val}`);
  313. // Convert to seconds
  314. const ms = (options.playerStartPositionTicks || 0) / 10000;
  315. this._currentPlayOptions = options;
  316. this._subtitleTrackIndexToSetOnPlaying = options.mediaSource.DefaultSubtitleStreamIndex == null ? -1 : options.mediaSource.DefaultSubtitleStreamIndex;
  317. this._audioTrackIndexToSetOnPlaying = options.playMethod === 'Transcode' ? null : options.mediaSource.DefaultAudioStreamIndex;
  318. const streamdata = {type: 'video', headers: {'User-Agent': 'JellyfinMediaPlayer'}, metadata: options.item, media: {}};
  319. const fps = this.tryGetFramerate(options);
  320. if (fps) {
  321. streamdata.frameRate = fps;
  322. }
  323. const player = window.api.player;
  324. player.load(val,
  325. { startMilliseconds: ms, autoplay: true },
  326. streamdata,
  327. this.getAudioParam(),
  328. this.getSubtitleParam(),
  329. resolve);
  330. });
  331. }
  332. setSubtitleStreamIndex(index) {
  333. this._subtitleTrackIndexToSetOnPlaying = index;
  334. window.api.player.setSubtitleStream(this.getSubtitleParam());
  335. }
  336. resetSubtitleOffset() {
  337. this._currentTrackOffset = 0;
  338. this._showTrackOffset = false;
  339. window.api.player.setSubtitleDelay(0);
  340. }
  341. enableShowingSubtitleOffset() {
  342. this._showTrackOffset = true;
  343. }
  344. disableShowingSubtitleOffset() {
  345. this._showTrackOffset = false;
  346. }
  347. isShowingSubtitleOffsetEnabled() {
  348. return this._showTrackOffset;
  349. }
  350. setSubtitleOffset(offset) {
  351. const offsetValue = parseFloat(offset);
  352. this._currentTrackOffset = offsetValue;
  353. window.api.player.setSubtitleDelay(Math.round(offsetValue * 1000));
  354. }
  355. getSubtitleOffset() {
  356. return this._currentTrackOffset;
  357. }
  358. /**
  359. * @private
  360. */
  361. isAudioStreamSupported() {
  362. return true;
  363. }
  364. /**
  365. * @private
  366. */
  367. getSupportedAudioStreams() {
  368. const profile = this._lastProfile;
  369. return getMediaStreamAudioTracks(this._currentPlayOptions.mediaSource).filter((stream) => {
  370. return this.isAudioStreamSupported(stream, profile);
  371. });
  372. }
  373. setAudioStreamIndex(index) {
  374. this._audioTrackIndexToSetOnPlaying = index;
  375. const streams = this.getSupportedAudioStreams();
  376. if (streams.length < 2) {
  377. // If there's only one supported stream then trust that the player will handle it on it's own
  378. return;
  379. }
  380. window.api.player.setAudioStream(this.getAudioParam());
  381. }
  382. onEndedInternal() {
  383. const stopInfo = {
  384. src: this._currentSrc
  385. };
  386. this.events.trigger(this, 'stopped', [stopInfo]);
  387. this._currentTime = null;
  388. this._currentSrc = null;
  389. this._currentPlayOptions = null;
  390. }
  391. stop(destroyPlayer) {
  392. window.api.player.stop();
  393. window.api.power.setScreensaverEnabled(true);
  394. this.onEndedInternal();
  395. if (destroyPlayer) {
  396. this.destroy();
  397. }
  398. return Promise.resolve();
  399. }
  400. removeMediaDialog() {
  401. this.loading.hide();
  402. window.api.player.stop();
  403. window.api.power.setScreensaverEnabled(true);
  404. this.setTransparency('none');
  405. document.body.classList.remove('hide-scroll');
  406. const dlg = this._videoDialog;
  407. if (dlg) {
  408. this._videoDialog = null;
  409. dlg.parentNode.removeChild(dlg);
  410. }
  411. // Only supporting QtWebEngine here
  412. if (document.webkitIsFullScreen && document.webkitExitFullscreen) {
  413. document.webkitExitFullscreen();
  414. }
  415. }
  416. destroy() {
  417. this.removeMediaDialog();
  418. const player = window.api.player;
  419. this._hasConnection = false;
  420. player.playing.disconnect(this.onPlaying);
  421. player.positionUpdate.disconnect(this.onTimeUpdate);
  422. player.finished.disconnect(this.onEnded);
  423. this._duration = undefined;
  424. player.updateDuration.disconnect(this.onDuration);
  425. player.error.disconnect(this.onError);
  426. player.paused.disconnect(this.onPause);
  427. }
  428. /**
  429. * @private
  430. */
  431. createMediaElement(options) {
  432. const dlg = document.querySelector('.videoPlayerContainer');
  433. if (!dlg) {
  434. this.loading.show();
  435. const dlg = document.createElement('div');
  436. dlg.classList.add('videoPlayerContainer');
  437. dlg.style.position = 'fixed';
  438. dlg.style.top = 0;
  439. dlg.style.bottom = 0;
  440. dlg.style.left = 0;
  441. dlg.style.right = 0;
  442. dlg.style.display = 'flex';
  443. dlg.style.alignItems = 'center';
  444. if (options.fullscreen) {
  445. dlg.style.zIndex = 1000;
  446. }
  447. const html = '';
  448. dlg.innerHTML = html;
  449. document.body.insertBefore(dlg, document.body.firstChild);
  450. this._videoDialog = dlg;
  451. const player = window.api.player;
  452. if (!this._hasConnection) {
  453. this._hasConnection = true;
  454. player.playing.connect(this.onPlaying);
  455. player.positionUpdate.connect(this.onTimeUpdate);
  456. player.finished.connect(this.onEnded);
  457. player.updateDuration.connect(this.onDuration);
  458. player.error.connect(this.onError);
  459. player.paused.connect(this.onPause);
  460. }
  461. if (options.fullscreen) {
  462. // At this point, we must hide the scrollbar placeholder, so it's not being displayed while the item is being loaded
  463. document.body.classList.add('hide-scroll');
  464. }
  465. return Promise.resolve();
  466. } else {
  467. // we need to hide scrollbar when starting playback from page with animated background
  468. if (options.fullscreen) {
  469. document.body.classList.add('hide-scroll');
  470. }
  471. return Promise.resolve();
  472. }
  473. }
  474. /**
  475. * @private
  476. */
  477. canPlayMediaType(mediaType) {
  478. return (mediaType || '').toLowerCase() === 'video';
  479. }
  480. /**
  481. * @private
  482. */
  483. supportsPlayMethod() {
  484. return true;
  485. }
  486. /**
  487. * @private
  488. */
  489. getDeviceProfile(item, options) {
  490. if (this.appHost.getDeviceProfile) {
  491. return this.appHost.getDeviceProfile(item, options);
  492. }
  493. return Promise.resolve({});
  494. }
  495. /**
  496. * @private
  497. */
  498. static getSupportedFeatures() {
  499. return ['PlaybackRate', 'SetAspectRatio'];
  500. }
  501. supports(feature) {
  502. if (!this._supportedFeatures) {
  503. this._supportedFeatures = mpvVideoPlayer.getSupportedFeatures();
  504. }
  505. return this._supportedFeatures.includes(feature);
  506. }
  507. // Save this for when playback stops, because querying the time at that point might return 0
  508. currentTime(val) {
  509. if (val != null) {
  510. window.api.player.seekTo(val);
  511. return;
  512. }
  513. return this._currentTime;
  514. }
  515. currentTimeAsync() {
  516. return new Promise((resolve) => {
  517. window.api.player.getPosition(resolve);
  518. });
  519. }
  520. duration() {
  521. if (this._duration) {
  522. return this._duration;
  523. }
  524. return null;
  525. }
  526. canSetAudioStreamIndex() {
  527. return true;
  528. }
  529. static onPictureInPictureError(err) {
  530. console.error(`Picture in picture error: ${err}`);
  531. }
  532. setPictureInPictureEnabled() {}
  533. isPictureInPictureEnabled() {
  534. return false;
  535. }
  536. isAirPlayEnabled() {
  537. return false;
  538. }
  539. setAirPlayEnabled() {}
  540. setBrightness() {}
  541. getBrightness() {
  542. return 100;
  543. }
  544. seekable() {
  545. return Boolean(this._duration);
  546. }
  547. pause() {
  548. window.api.player.pause();
  549. window.api.power.setScreensaverEnabled(true);
  550. }
  551. // This is a retry after error
  552. resume() {
  553. this._paused = false;
  554. window.api.player.play();
  555. }
  556. unpause() {
  557. window.api.player.play();
  558. window.api.power.setScreensaverEnabled(false);
  559. }
  560. paused() {
  561. return this._paused;
  562. }
  563. setPlaybackRate(value) {
  564. let playSpeed = +value; //this comes as a string from player force int for now
  565. this._playRate = playSpeed;
  566. window.api.player.setPlaybackRate(playSpeed * 1000);
  567. }
  568. getPlaybackRate() {
  569. if(!this._playRate) //On startup grab default
  570. {
  571. let playRate = window.jmpInfo.settings.video.default_playback_speed;
  572. if(!playRate) //fallback if default missing
  573. playRate = 1;
  574. this._playRate = playRate;
  575. }
  576. return this._playRate;
  577. }
  578. getSupportedPlaybackRates() {
  579. return [{
  580. name: '0.5x',
  581. id: 0.5
  582. }, {
  583. name: '0.75x',
  584. id: 0.75
  585. }, {
  586. name: '1x',
  587. id: 1.0
  588. }, {
  589. name: '1.25x',
  590. id: 1.25
  591. }, {
  592. name: '1.5x',
  593. id: 1.5
  594. }, {
  595. name: '1.75x',
  596. id: 1.75
  597. }, {
  598. name: '2x',
  599. id: 2.0
  600. }];
  601. }
  602. saveVolume(value) {
  603. if (value) {
  604. this.appSettings.set('volume', value);
  605. }
  606. }
  607. setVolume(val, save = true) {
  608. this._volume = val;
  609. if (save) {
  610. this.saveVolume((val || 100) / 100);
  611. this.events.trigger(this, 'volumechange');
  612. }
  613. window.api.player.setVolume(val);
  614. }
  615. getVolume() {
  616. return this._volume;
  617. }
  618. volumeUp() {
  619. this.setVolume(Math.min(this.getVolume() + 2, 100));
  620. }
  621. volumeDown() {
  622. this.setVolume(Math.max(this.getVolume() - 2, 0));
  623. }
  624. setMute(mute, triggerEvent = true) {
  625. this._muted = mute;
  626. window.api.player.setMuted(mute);
  627. if (triggerEvent) {
  628. this.events.trigger(this, 'volumechange');
  629. }
  630. }
  631. isMuted() {
  632. return this._muted;
  633. }
  634. togglePictureInPicture() {
  635. }
  636. toggleAirPlay() {
  637. }
  638. getBufferedRanges() {
  639. return [];
  640. }
  641. getStats() {
  642. const playOptions = this._currentPlayOptions || [];
  643. const categories = [];
  644. if (!this._currentPlayOptions) {
  645. return Promise.resolve({
  646. categories: categories
  647. });
  648. }
  649. const mediaCategory = {
  650. stats: [],
  651. type: 'media'
  652. };
  653. categories.push(mediaCategory);
  654. if (playOptions.url) {
  655. // create an anchor element (note: no need to append this element to the document)
  656. let link = document.createElement('a');
  657. // set href to any path
  658. link.setAttribute('href', playOptions.url);
  659. const protocol = (link.protocol || '').replace(':', '');
  660. if (protocol) {
  661. mediaCategory.stats.push({
  662. label: this.globalize.translate('LabelProtocol'),
  663. value: protocol
  664. });
  665. }
  666. link = null;
  667. }
  668. mediaCategory.stats.push({
  669. label: this.globalize.translate('LabelStreamType'),
  670. value: 'Video'
  671. });
  672. const videoCategory = {
  673. stats: [],
  674. type: 'video'
  675. };
  676. categories.push(videoCategory);
  677. const audioCategory = {
  678. stats: [],
  679. type: 'audio'
  680. };
  681. categories.push(audioCategory);
  682. return Promise.resolve({
  683. categories: categories
  684. });
  685. }
  686. getSupportedAspectRatios() {
  687. const options = window.jmpInfo.settingsDescriptions.video.find(x => x.key == 'aspect').options;
  688. const current = window.jmpInfo.settings.video.aspect;
  689. const getOptionName = (option) => {
  690. const canTranslate = {
  691. 'normal': 'Auto',
  692. 'zoom': 'AspectRatioCover',
  693. 'stretch': 'AspectRatioFill',
  694. }
  695. const name = option.replace('video.aspect.', '');
  696. return canTranslate[name]
  697. ? this.globalize.translate(canTranslate[name])
  698. : name;
  699. }
  700. return options.map(x => ({
  701. id: x.value,
  702. name: getOptionName(x.title),
  703. selected: x.value == current
  704. }));
  705. }
  706. getAspectRatio() {
  707. return window.jmpInfo.settings.video.aspect;
  708. }
  709. setAspectRatio(value) {
  710. window.jmpInfo.settings.video.aspect = value;
  711. }
  712. }
  713. /* eslint-enable indent */
  714. window._mpvVideoPlayer = mpvVideoPlayer;