Skip to content

Commit

Permalink
Fix: [Client][Player/PlayerController] PlayerController.destroy() で設定…
Browse files Browse the repository at this point in the history
…したウォッチャーが適切に破棄されない問題を修正
  • Loading branch information
tsukumijima committed Oct 7, 2024
1 parent 68f62d8 commit ad33c0b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions client/src/services/player/PlayerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import Hls from 'hls.js';
import mpegts from 'mpegts.js';
import { watch } from 'vue';

import KeyboardShortcutManager from './managers/KeyboardShortcutManager';

import APIClient from '@/services/APIClient';
import CaptureManager from '@/services/player/managers/CaptureManager';
import DocumentPiPManager from '@/services/player/managers/DocumentPiPManager';
import KeyboardShortcutManager from '@/services/player/managers/KeyboardShortcutManager';
import LiveCommentManager from '@/services/player/managers/LiveCommentManager';
import LiveDataBroadcastingManager from '@/services/player/managers/LiveDataBroadcastingManager';
import LiveEventManager from '@/services/player/managers/LiveEventManager';
Expand Down Expand Up @@ -78,6 +77,9 @@ class PlayerController {
private readonly romsounds_context: AudioContext = new AudioContext();
private readonly romsounds_buffers: AudioBuffer[] = [];

// L字画面のクロップ設定で使うウォッチャーを保持する配列
private lshaped_screen_crop_watchers: (() => void)[] = [];

// 破棄中かどうか
// 破棄中は destroy() が呼ばれても何もしない
private destroying = false;
Expand Down Expand Up @@ -584,7 +586,7 @@ class PlayerController {
// DPlayer の設定パネルを無理やり拡張し、KonomiTV 独自の項目を追加する
this.setupSettingPanelHandler();

// LShaped Screen Crop の設定が変更されたときのイベントハンドラーを登録する
// L字画面のクロップ設定が変更されたときのイベントハンドラーを登録する
this.setupLShapedScreenCropHandler();

// KonomiTV 本体の UI を含むプレイヤー全体のコンテナ要素がリサイズされたときのイベントハンドラーを登録する
Expand Down Expand Up @@ -1352,11 +1354,13 @@ class PlayerController {
crop();

// 設定値が変更されたときに実行
watch(() => settings_store.settings.lshaped_screen_crop_enabled, crop, { immediate: true });
watch(() => settings_store.settings.lshaped_screen_crop_zoom_level, crop, { immediate: true });
watch(() => settings_store.settings.lshaped_screen_crop_x_position, crop, { immediate: true });
watch(() => settings_store.settings.lshaped_screen_crop_y_position, crop, { immediate: true });
watch(() => settings_store.settings.lshaped_screen_crop_zoom_origin, crop, { immediate: true });
this.lshaped_screen_crop_watchers = [
watch(() => settings_store.settings.lshaped_screen_crop_enabled, crop, { immediate: true }),
watch(() => settings_store.settings.lshaped_screen_crop_zoom_level, crop, { immediate: true }),
watch(() => settings_store.settings.lshaped_screen_crop_x_position, crop, { immediate: true }),
watch(() => settings_store.settings.lshaped_screen_crop_y_position, crop, { immediate: true }),
watch(() => settings_store.settings.lshaped_screen_crop_zoom_origin, crop, { immediate: true }),
];
}


Expand Down Expand Up @@ -1617,6 +1621,12 @@ class PlayerController {
this.player_container_resize_observer = null;
}

// L字画面のクロップ設定で使うウォッチャーを破棄
if (this.lshaped_screen_crop_watchers.length > 0) {
this.lshaped_screen_crop_watchers.forEach((unwatcher) => unwatcher());
this.lshaped_screen_crop_watchers = [];
}

// DPlayer 本体を破棄
// なぜか例外が出ることがあるので try-catch で囲む
if (this.player !== null) {
Expand Down

0 comments on commit ad33c0b

Please sign in to comment.