From ad33c0b106d90debce4461841d35a13e7834b5ff Mon Sep 17 00:00:00 2001 From: tsukumi Date: Mon, 7 Oct 2024 13:14:40 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20[Client][Player/PlayerController]=20Play?= =?UTF-8?q?erController.destroy()=20=E3=81=A7=E8=A8=AD=E5=AE=9A=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=82=A6=E3=82=A9=E3=83=83=E3=83=81=E3=83=A3=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E9=81=A9=E5=88=87=E3=81=AB=E7=A0=B4=E6=A3=84=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/services/player/PlayerController.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/client/src/services/player/PlayerController.ts b/client/src/services/player/PlayerController.ts index 8ac25ef4..03479627 100644 --- a/client/src/services/player/PlayerController.ts +++ b/client/src/services/player/PlayerController.ts @@ -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'; @@ -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; @@ -584,7 +586,7 @@ class PlayerController { // DPlayer の設定パネルを無理やり拡張し、KonomiTV 独自の項目を追加する this.setupSettingPanelHandler(); - // LShaped Screen Crop の設定が変更されたときのイベントハンドラーを登録する + // L字画面のクロップ設定が変更されたときのイベントハンドラーを登録する this.setupLShapedScreenCropHandler(); // KonomiTV 本体の UI を含むプレイヤー全体のコンテナ要素がリサイズされたときのイベントハンドラーを登録する @@ -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 }), + ]; } @@ -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) {