diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 7b568a5..850294f 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -1850,7 +1850,8 @@ function PlayPageClient() { setDanmakuLoading(true); try { - // 先清空当前弹幕 + // 先清空当前弹幕并隐藏 + danmakuPluginRef.current.hide(); danmakuPluginRef.current.config({ danmuku: [], }); @@ -1901,12 +1902,25 @@ function PlayPageClient() { } } - // 加载弹幕到插件 + // 加载弹幕到插件,同时应用当前的弹幕设置 + const currentSettings = danmakuSettingsRef.current; danmakuPluginRef.current.config({ danmuku: danmakuData, + speed: currentSettings.speed, + opacity: currentSettings.opacity, + fontSize: currentSettings.fontSize, + margin: [currentSettings.marginTop, currentSettings.marginBottom], + synchronousPlayback: currentSettings.synchronousPlayback, }); danmakuPluginRef.current.load(); + // 根据设置显示或隐藏弹幕 + if (currentSettings.enabled) { + danmakuPluginRef.current.show(); + } else { + danmakuPluginRef.current.hide(); + } + setDanmakuCount(danmakuData.length); console.log(`弹幕加载成功,共 ${danmakuData.length} 条`);