From 810719ee2605422166da53594363bc8d55692616 Mon Sep 17 00:00:00 2001 From: WindowsMEMZ Date: Sun, 17 Mar 2024 00:11:15 +0800 Subject: [PATCH] feat: Update Video Player --- .swiftlint.yml | 1 + DarockBili.xcodeproj/project.pbxproj | 24 +++---- .../xcshareddata/WorkspaceSettings.xcsettings | 5 ++ Localizable.xcstrings | 62 ++++++++++++++++--- MeowBili/Others/SettingsView.swift | 13 +++- MeowBili/Video/VideoPlayerView.swift | 53 +++++++++++++++- 6 files changed, 135 insertions(+), 23 deletions(-) create mode 100644 DarockBili.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/.swiftlint.yml b/.swiftlint.yml index 17338a233..aa8552ddb 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -12,6 +12,7 @@ disabled_rules: - force_try - syntactic_sugar - for_where + - legacy_constant opt_in_rules: - attributes diff --git a/DarockBili.xcodeproj/project.pbxproj b/DarockBili.xcodeproj/project.pbxproj index 0da6459e0..6c8ba5223 100644 --- a/DarockBili.xcodeproj/project.pbxproj +++ b/DarockBili.xcodeproj/project.pbxproj @@ -1579,7 +1579,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = SafariExtension/Info.plist; @@ -1610,7 +1610,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = SafariExtension/Info.plist; @@ -1646,7 +1646,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1681,7 +1681,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1718,7 +1718,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1765,7 +1765,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1809,7 +1809,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1845,7 +1845,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1884,7 +1884,7 @@ CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_HARDENED_RUNTIME = YES; @@ -1917,7 +1917,7 @@ CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_HARDENED_RUNTIME = YES; @@ -1946,7 +1946,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -1969,7 +1969,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 900; + CURRENT_PROJECT_VERSION = 904; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 16.0; diff --git a/DarockBili.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/DarockBili.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..0c67376eb --- /dev/null +++ b/DarockBili.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,5 @@ + + + + + diff --git a/Localizable.xcstrings b/Localizable.xcstrings index de76fd004..8097265c6 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -507,6 +507,21 @@ } } } + }, + "1.5x" : { + + }, + "1x" : { + + }, + "2x" : { + + }, + "3x" : { + + }, + "5x" : { + }, "114" : { "localizations" : { @@ -2760,24 +2775,24 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "Double-tap to Play/Pause Video" + "value" : "Double-tap to Take Action" } }, "ja" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "ビデオの再生/一時停止には、軽く2回タップしてください。" } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "轻点两下以播放/暂停视频" + "value" : "轻点两下执行操作" } }, "zh-Hant" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "輕點兩下以播放/暫停視頻" } } @@ -2788,24 +2803,24 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "Use Double-tap (Apple Watch Series 9 or newer) or Quick Actions (other watches) in video player to play/pause video" + "value" : "Use Double-tap Quick Actions (open at system settings->Accessibility) in video player to take action" } }, "ja" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "ビデオプレーヤーで、Apple Watch Series 9以上のモデルではダブルタップジェスチャーを使用し、他のモデルではクイックアクションを使用してビデオの再生/一時停止を行います。" } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "在视频播放器中使用互点两下手势(Apple Watch Series 9 及以上)或快速操作(其他机型)播放/暂停视频" + "value" : "在视频播放器中使用快速操作(于系统设置->辅助功能中打开)执行操作" } }, "zh-Hant" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "在視頻播放器中使用雙擊手勢(適用於 Apple Watch Series 9 及以上版本)或快速操作(適用於其他型號)來播放/暂停視頻。" } } @@ -4093,6 +4108,7 @@ } }, "Player.pause" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { @@ -4231,6 +4247,9 @@ } } } + }, + "PlayerGesture" : { + }, "Screen-time.daily-average" : { "localizations" : { @@ -8653,6 +8672,12 @@ } } } + }, + "快进 10 秒" : { + + }, + "快退 10 秒" : { + }, "恢复" : { "localizations" : { @@ -8757,6 +8782,15 @@ }, "搜索" : { + }, + "播放" : { + + }, + "播放/暂停" : { + + }, + "播放倍速" : { + }, "文件保险箱" : { @@ -8878,6 +8912,9 @@ } } } + }, + "暂停->退出" : { + }, "来自" : { @@ -9096,6 +9133,9 @@ }, "编辑" : { + }, + "行为" : { + }, "要使用动态小尾巴吗?" : { "localizations" : { @@ -9235,6 +9275,12 @@ }, "输入错误" : { + }, + "退出" : { + + }, + "退出 App" : { + }, "选择图片" : { "localizations" : { diff --git a/MeowBili/Others/SettingsView.swift b/MeowBili/Others/SettingsView.swift index 3a8a478eb..59f656c47 100644 --- a/MeowBili/Others/SettingsView.swift +++ b/MeowBili/Others/SettingsView.swift @@ -950,12 +950,23 @@ struct SoftwareUpdateView: View { struct GestureSettingsView: View { @AppStorage("IsVideoPlayerGestureEnabled") var isVideoPlayerGestureEnabled = true + @AppStorage("VideoPlayerGestureBehavior") var videoPlayerGestureBehavior = "Play/Pause" var body: some View { List { Section { Toggle("Gesture.double-tap", isOn: $isVideoPlayerGestureEnabled) } footer: { - Text("Gesture.double-tap.description") //在视频播放器使用互点两下手势(Apple Watch Series 9 及以上)或快速操作(其他机型)暂停或播放视频 + Text("Gesture.double-tap.description") + } + if isVideoPlayerGestureEnabled { + Section { + Picker("行为", selection: $videoPlayerGestureBehavior) { + Text("播放/暂停").tag("Play/Pause") + Text("暂停->退出").tag("Pause/Exit") + Text("退出播放").tag("Exit") + Text("退出 App").tag("Exit App") + } + } } } } diff --git a/MeowBili/Video/VideoPlayerView.swift b/MeowBili/Video/VideoPlayerView.swift index 516b9ab54..97ee3c7e2 100644 --- a/MeowBili/Video/VideoPlayerView.swift +++ b/MeowBili/Video/VideoPlayerView.swift @@ -38,6 +38,9 @@ struct VideoPlayerView: View { @Binding var currentPlayTime: Double @Binding var willEnterGoodVideo: Bool #endif + #if os(watchOS) + @Environment(\.dismiss) var dismiss + #endif @AppStorage("DedeUserID") var dedeUserID = "" @AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = "" @AppStorage("SESSDATA") var sessdata = "" @@ -51,8 +54,10 @@ struct VideoPlayerView: View { @AppStorage("RecordHistoryTime") var recordHistoryTime = "into" @AppStorage("IsDanmakuEnabled") var isDanmakuEnabled = true @AppStorage("IsVideoPlayerGestureEnabled") var isVideoPlayerGestureEnabled = true + @AppStorage("VideoPlayerGestureBehavior") var videoPlayerGestureBehavior = "Play/Pause" @State var tabviewChoseTab = 1 @State var isFullScreen = false + @State var videoSpeed: Float = 1.0 #endif @State var currentTime: Double = 0.0 @State var playerTimer: Timer? @@ -185,6 +190,30 @@ struct VideoPlayerView: View { } header: { Text("弹幕") } + Section { + Picker("播放倍速", selection: $videoSpeed) { + Text("1x").tag(1.0) + Text("1.5x").tag(1.5) + Text("2x").tag(2.0) + Text("3x").tag(3.0) + Text("5x").tag(5.0) + } + .onChange(of: videoSpeed) { value in + player.rate = value + } + Button(action: { + player.seek(to: CMTime(seconds: currentTime + 10, preferredTimescale: 1)) + }, label: { + Label("快进 10 秒", systemImage: "goforward.10") + }) + Button(action: { + player.seek(to: CMTime(seconds: currentTime - 10, preferredTimescale: 1)) + }, label: { + Label("快退 10 秒", systemImage: "gobackward.10") + }) + } header: { + Text("播放") + } } .tag(2) } @@ -193,9 +222,29 @@ struct VideoPlayerView: View { .accessibilityQuickAction(style: .prompt) { if isVideoPlayerGestureEnabled { Button(action: { - player?.pause() + switch videoPlayerGestureBehavior { + case "Play/Pause": + if player.timeControlStatus == .playing { + player.pause() + } else if player.timeControlStatus == .paused { + player.play() + } + case "Pause/Exit": + if player.timeControlStatus == .playing { + player.pause() + } else if player.timeControlStatus == .paused { + dismiss() + } + case "Exit": + player.pause() + dismiss() + case "Exit App": + exit(0) + default: + break + } }, label: { - Text("Player.pause") + Text("PlayerGesture") }) } }