From 58d9bfe49bbf5c28d754e5cea7437cf4d0b4b914 Mon Sep 17 00:00:00 2001 From: aaa1115910 Date: Sun, 22 Dec 2024 12:59:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=B9=B6=E8=A1=A5=E5=85=A8=E5=81=B7=E6=87=92=E6=B2=A1?= =?UTF-8?q?=E5=86=99=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `DanmakuWebmark` -> `DanmakuMask` --- .../component/controllers/VideoPlayerController.kt | 1 + .../bv/component/controllers2/MenuController.kt | 11 ++++++++++- .../component/controllers2/VideoPlayerController.kt | 2 ++ .../component/controllers2/playermenu/DanmakuMenu.kt | 10 +++++----- .../dev/aaa1115910/bv/screen/VideoPlayerV3Screen.kt | 9 +++++++-- app/src/main/kotlin/dev/aaa1115910/bv/util/Prefs.kt | 12 +++++++----- .../bv/viewmodel/VideoPlayerV3ViewModel.kt | 1 + app/src/main/res/values/strings.xml | 4 ++-- 8 files changed, 35 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers/VideoPlayerController.kt b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers/VideoPlayerController.kt index 19a22703..6f44e62b 100644 --- a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers/VideoPlayerController.kt +++ b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers/VideoPlayerController.kt @@ -484,6 +484,7 @@ data class VideoPlayerControllerData( val currentDanmakuTransparency: DanmakuTransparency = DanmakuTransparency.T1, val currentDanmakuOpacity: Float = 1f, val currentDanmakuArea: Float = 1f, + val currentDanmakuMask: Boolean = false, val currentSubtitleId: Long = 0, val currentSubtitleData: List = emptyList(), val currentPosition: Long = 0, diff --git a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/MenuController.kt b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/MenuController.kt index d74af740..817f3a32 100644 --- a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/MenuController.kt +++ b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/MenuController.kt @@ -76,6 +76,7 @@ fun MenuController( onDanmakuSizeChange: (Float) -> Unit, onDanmakuOpacityChange: (Float) -> Unit, onDanmakuAreaChange: (Float) -> Unit, + onDanmakuMaskChange: (Boolean) -> Unit = {}, onSubtitleChange: (Subtitle) -> Unit, onSubtitleSizeChange: (TextUnit) -> Unit, onSubtitleBackgroundOpacityChange: (Float) -> Unit, @@ -111,6 +112,7 @@ fun MenuController( onDanmakuSizeChange = onDanmakuSizeChange, onDanmakuOpacityChange = onDanmakuOpacityChange, onDanmakuAreaChange = onDanmakuAreaChange, + onDanmakuMaskChange = onDanmakuMaskChange, onSubtitleChange = onSubtitleChange, onSubtitleSizeChange = onSubtitleSizeChange, onSubtitleBackgroundOpacityChange = onSubtitleBackgroundOpacityChange, @@ -133,6 +135,7 @@ fun MenuController( onDanmakuSizeChange: (Float) -> Unit, onDanmakuOpacityChange: (Float) -> Unit, onDanmakuAreaChange: (Float) -> Unit, + onDanmakuMaskChange: (Boolean) -> Unit = {}, onSubtitleChange: (Subtitle) -> Unit, onSubtitleSizeChange: (TextUnit) -> Unit, onSubtitleBackgroundOpacityChange: (Float) -> Unit, @@ -168,6 +171,7 @@ fun MenuController( onDanmakuSizeChange = onDanmakuSizeChange, onDanmakuOpacityChange = onDanmakuOpacityChange, onDanmakuAreaChange = onDanmakuAreaChange, + onDanmakuMaskChange = onDanmakuMaskChange, onFocusStateChange = { focusState = it }, onSubtitleChange = onSubtitleChange, onSubtitleSizeChange = onSubtitleSizeChange, @@ -209,6 +213,7 @@ private fun MenuList( onDanmakuSizeChange: (Float) -> Unit, onDanmakuOpacityChange: (Float) -> Unit, onDanmakuAreaChange: (Float) -> Unit, + onDanmakuMaskChange: (Boolean) -> Unit = {}, onSubtitleChange: (Subtitle) -> Unit, onSubtitleSizeChange: (TextUnit) -> Unit, onSubtitleBackgroundOpacityChange: (Float) -> Unit, @@ -238,6 +243,7 @@ private fun MenuList( onDanmakuOpacityChange = onDanmakuOpacityChange, onDanmakuAreaChange = onDanmakuAreaChange, onFocusStateChange = onFocusStateChange, + onDanmakuMaskChange = onDanmakuMaskChange ) } @@ -278,7 +284,7 @@ enum class VideoPlayerDanmakuMenuItem(private val strRes: Int) { Size(R.string.video_player_menu_danmaku_size), Opacity(R.string.video_player_menu_danmaku_opacity), Area(R.string.video_player_menu_danmaku_area), - Webmark(R.string.video_player_menu_danmaku_webmark); + Mask(R.string.video_player_menu_danmaku_mask); fun getDisplayName(context: Context) = context.getString(strRes) } @@ -317,6 +323,7 @@ fun MenuControllerPreview() { var currentDanmakuSize by remember { mutableFloatStateOf(1f) } var currentDanmakuOpacity by remember { mutableFloatStateOf(1f) } var currentDanmakuArea by remember { mutableFloatStateOf(1f) } + var currentDanmakuMask by remember { mutableStateOf(false) } var currentSubtitleId by remember { mutableLongStateOf(-1L) } val currentSubtitleList = remember { mutableStateListOf() } @@ -398,6 +405,7 @@ fun MenuControllerPreview() { currentDanmakuScale = currentDanmakuSize, currentDanmakuOpacity = currentDanmakuOpacity, currentDanmakuArea = currentDanmakuArea, + currentDanmakuMask = currentDanmakuMask, currentSubtitleId = currentSubtitleId, availableSubtitleTracks = currentSubtitleList, @@ -426,6 +434,7 @@ fun MenuControllerPreview() { onDanmakuSizeChange = { currentDanmakuSize = it }, onDanmakuOpacityChange = { currentDanmakuOpacity = it }, onDanmakuAreaChange = { currentDanmakuArea = it }, + onDanmakuMaskChange = { currentDanmakuMask = it }, onSubtitleChange = { currentSubtitleId = it.id }, onSubtitleSizeChange = { currentSubtitleFontSize = it }, onSubtitleBackgroundOpacityChange = { diff --git a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/VideoPlayerController.kt b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/VideoPlayerController.kt index c69ac873..e11290eb 100644 --- a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/VideoPlayerController.kt +++ b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/VideoPlayerController.kt @@ -70,6 +70,7 @@ fun VideoPlayerController( onDanmakuSizeChange: (Float) -> Unit, onDanmakuOpacityChange: (Float) -> Unit, onDanmakuAreaChange: (Float) -> Unit, + onDanmakuMaskChange: (Boolean) -> Unit, onSubtitleChange: (Subtitle) -> Unit, onSubtitleSizeChange: (TextUnit) -> Unit, onSubtitleBackgroundOpacityChange: (Float) -> Unit, @@ -365,6 +366,7 @@ fun VideoPlayerController( onDanmakuSizeChange = onDanmakuSizeChange, onDanmakuOpacityChange = onDanmakuOpacityChange, onDanmakuAreaChange = onDanmakuAreaChange, + onDanmakuMaskChange = onDanmakuMaskChange, onSubtitleChange = onSubtitleChange, onSubtitleSizeChange = onSubtitleSizeChange, onSubtitleBackgroundOpacityChange = onSubtitleBackgroundOpacityChange, diff --git a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/playermenu/DanmakuMenu.kt b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/playermenu/DanmakuMenu.kt index 1469809a..69161c66 100644 --- a/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/playermenu/DanmakuMenu.kt +++ b/app/src/main/kotlin/dev/aaa1115910/bv/component/controllers2/playermenu/DanmakuMenu.kt @@ -36,7 +36,6 @@ import dev.aaa1115910.bv.component.controllers2.playermenu.component.RadioMenuLi import dev.aaa1115910.bv.component.controllers2.playermenu.component.StepLessMenuItem import dev.aaa1115910.bv.component.createCustomInitialFocusRestorerModifiers import dev.aaa1115910.bv.component.ifElse -import dev.aaa1115910.bv.util.Prefs import java.text.NumberFormat @Composable @@ -46,6 +45,7 @@ fun DanmakuMenuList( onDanmakuSizeChange: (Float) -> Unit, onDanmakuOpacityChange: (Float) -> Unit, onDanmakuAreaChange: (Float) -> Unit, + onDanmakuMaskChange: (Boolean) -> Unit, onFocusStateChange: (MenuFocusState) -> Unit ) { val context = LocalContext.current @@ -61,7 +61,7 @@ fun DanmakuMenuList( verticalAlignment = Alignment.CenterVertically ) { val menuItemsModifier = Modifier - .width(200.dp) + .width(216.dp) .padding(horizontal = 8.dp) AnimatedVisibility(visible = focusState.focusState != MenuFocusState.MenuNav) { when (selectedDanmakuMenuItem) { @@ -146,11 +146,11 @@ fun DanmakuMenuList( onFocusBackToParent = { onFocusStateChange(MenuFocusState.Menu) } ) - VideoPlayerDanmakuMenuItem.Webmark -> RadioMenuList( + VideoPlayerDanmakuMenuItem.Mask -> RadioMenuList( modifier = menuItemsModifier, items = listOf("关闭", "开启"), - selected = if (Prefs.enableWebmark) 1 else 0, - onSelectedChanged = { Prefs.enableWebmark = it == 1 }, + selected = if (data.currentDanmakuMask) 1 else 0, + onSelectedChanged = { onDanmakuMaskChange(it == 1) }, onFocusBackToParent = { onFocusStateChange(MenuFocusState.Menu) } ) } diff --git a/app/src/main/kotlin/dev/aaa1115910/bv/screen/VideoPlayerV3Screen.kt b/app/src/main/kotlin/dev/aaa1115910/bv/screen/VideoPlayerV3Screen.kt index 4bf7d66f..ffcd8668 100644 --- a/app/src/main/kotlin/dev/aaa1115910/bv/screen/VideoPlayerV3Screen.kt +++ b/app/src/main/kotlin/dev/aaa1115910/bv/screen/VideoPlayerV3Screen.kt @@ -32,7 +32,6 @@ import com.kuaishou.akdanmaku.data.DanmakuItemData import com.kuaishou.akdanmaku.ecs.component.filter.TypeFilter import com.kuaishou.akdanmaku.ext.RETAINER_BILIBILI import dev.aaa1115910.biliapi.entity.danmaku.DanmakuMaskFrame -import dev.aaa1115910.biliapi.entity.video.VideoShot import dev.aaa1115910.bv.component.DanmakuPlayerCompose import dev.aaa1115910.bv.component.controllers.LocalVideoPlayerControllerData import dev.aaa1115910.bv.component.controllers.VideoPlayerControllerData @@ -447,6 +446,7 @@ fun VideoPlayerV3Screen( currentDanmakuScale = playerViewModel.currentDanmakuScale, currentDanmakuOpacity = playerViewModel.currentDanmakuOpacity, currentDanmakuArea = playerViewModel.currentDanmakuArea, + currentDanmakuMask = playerViewModel.currentDanmakuMask, currentSubtitleId = playerViewModel.currentSubtitleId, currentSubtitleData = playerViewModel.currentSubtitleData, currentSubtitleFontSize = playerViewModel.currentSubtitleFontSize, @@ -588,6 +588,11 @@ fun VideoPlayerV3Screen( Prefs.defaultDanmakuArea = area playerViewModel.currentDanmakuArea = area }, + onDanmakuMaskChange = { mask -> + logger.info { "On danmaku mask change: $mask" } + Prefs.defaultDanmakuMask = mask + playerViewModel.currentDanmakuMask = mask + }, onSubtitleChange = { subtitle -> playerViewModel.loadSubtitle(subtitle.id) }, @@ -634,7 +639,7 @@ fun VideoPlayerV3Screen( // 突然变成完全不透明一瞬间,因此这次新版选择直接在此处设置透明度 .alpha(playerViewModel.currentDanmakuOpacity) .ifElse( - { Prefs.enableWebmark }, + { playerViewModel.currentDanmakuMask }, Modifier.danmakuMask(currentDanmakuMaskFrame) ), danmakuPlayer = playerViewModel.danmakuPlayer diff --git a/app/src/main/kotlin/dev/aaa1115910/bv/util/Prefs.kt b/app/src/main/kotlin/dev/aaa1115910/bv/util/Prefs.kt index 117d58ba..8e88d3a5 100644 --- a/app/src/main/kotlin/dev/aaa1115910/bv/util/Prefs.kt +++ b/app/src/main/kotlin/dev/aaa1115910/bv/util/Prefs.kt @@ -279,9 +279,11 @@ object Prefs { get() = runBlocking { dsm.getPreferenceFlow(PrefKeys.prefPreferOfficialCdnRequest).first() } set(value) = runBlocking { dsm.editPreference(PrefKeys.prefPreferOfficialCdn, value) } - var enableWebmark: Boolean - get() = runBlocking { dsm.getPreferenceFlow(PrefKeys.prefPreferEnableWebmarkRequest).first() } - set(value) = runBlocking { dsm.editPreference(PrefKeys.prefEnableWebmark, value) } + var defaultDanmakuMask: Boolean + get() = runBlocking { + dsm.getPreferenceFlow(PrefKeys.prefDefaultDanmakuMaskRequest).first() + } + set(value) = runBlocking { dsm.editPreference(PrefKeys.prefDefaultDanmakuMask, value) } } private object PrefKeys { @@ -324,7 +326,7 @@ private object PrefKeys { val prefLastVersionCodeKey = intPreferencesKey("last_version_code") val prefShowedRemoteControllerPanelDemoKey = booleanPreferencesKey("showed_rcpd") val prefPreferOfficialCdn = booleanPreferencesKey("prefer_official_cdn") - val prefEnableWebmark = booleanPreferencesKey("prefer_enable_webmark") + val prefDefaultDanmakuMask = booleanPreferencesKey("prefer_enable_webmark") val prefIsLoginRequest = PreferenceRequest(prefIsLoginKey, false) val prefUidRequest = PreferenceRequest(prefUidKey, 0) @@ -375,5 +377,5 @@ private object PrefKeys { val prefShowedRemoteControllerPanelDemoRequest = PreferenceRequest(prefShowedRemoteControllerPanelDemoKey, false) val prefPreferOfficialCdnRequest = PreferenceRequest(prefPreferOfficialCdn, false) - val prefPreferEnableWebmarkRequest = PreferenceRequest(prefEnableWebmark, false) + val prefDefaultDanmakuMaskRequest = PreferenceRequest(prefDefaultDanmakuMask, false) } \ No newline at end of file diff --git a/app/src/main/kotlin/dev/aaa1115910/bv/viewmodel/VideoPlayerV3ViewModel.kt b/app/src/main/kotlin/dev/aaa1115910/bv/viewmodel/VideoPlayerV3ViewModel.kt index b0d64965..29d236af 100644 --- a/app/src/main/kotlin/dev/aaa1115910/bv/viewmodel/VideoPlayerV3ViewModel.kt +++ b/app/src/main/kotlin/dev/aaa1115910/bv/viewmodel/VideoPlayerV3ViewModel.kt @@ -90,6 +90,7 @@ class VideoPlayerV3ViewModel( addAll(Prefs.defaultDanmakuTypes) } var currentDanmakuArea by mutableFloatStateOf(Prefs.defaultDanmakuArea) + var currentDanmakuMask by mutableStateOf(Prefs.defaultDanmakuMask) var currentSubtitleId by mutableLongStateOf(-1L) var currentSubtitleData = mutableStateListOf() var currentSubtitleFontSize by mutableStateOf(Prefs.defaultSubtitleFontSize) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 182c3b29..47451077 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -179,7 +179,6 @@ HDR 历史记录 - 现在不看 bilibili 热搜 清空 删除 @@ -279,6 +278,7 @@ 设置 网络测速 视频标签 + 现在不看 UP 投稿 用户信息 用户锁设置 @@ -465,6 +465,7 @@ 标签 投稿时间: %1$s 显示区域 + 防遮挡 不透明度 字体缩放 弹幕类型 @@ -472,7 +473,6 @@ 底部弹幕 滚动弹幕 顶部弹幕 - 防遮挡 弹幕设置 画面音频 字幕设置