Skip to content

Commit

Permalink
feat: Update Video Player
Browse files Browse the repository at this point in the history
  • Loading branch information
WindowsMEMZ committed Mar 16, 2024
1 parent b73ffa1 commit 810719e
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 23 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ disabled_rules:
- force_try
- syntactic_sugar
- for_where
- legacy_constant

opt_in_rules:
- attributes
Expand Down
24 changes: 12 additions & 12 deletions DarockBili.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
62 changes: 54 additions & 8 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,21 @@
}
}
}
},
"1.5x" : {

},
"1x" : {

},
"2x" : {

},
"3x" : {

},
"5x" : {

},
"114" : {
"localizations" : {
Expand Down Expand Up @@ -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" : "輕點兩下以播放/暫停視頻"
}
}
Expand All @@ -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 及以上版本)或快速操作(適用於其他型號)來播放/暂停視頻。"
}
}
Expand Down Expand Up @@ -4093,6 +4108,7 @@
}
},
"Player.pause" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
Expand Down Expand Up @@ -4231,6 +4247,9 @@
}
}
}
},
"PlayerGesture" : {

},
"Screen-time.daily-average" : {
"localizations" : {
Expand Down Expand Up @@ -8653,6 +8672,12 @@
}
}
}
},
"快进 10 秒" : {

},
"快退 10 秒" : {

},
"恢复" : {
"localizations" : {
Expand Down Expand Up @@ -8757,6 +8782,15 @@
},
"搜索" : {

},
"播放" : {

},
"播放/暂停" : {

},
"播放倍速" : {

},
"文件保险箱" : {

Expand Down Expand Up @@ -8878,6 +8912,9 @@
}
}
}
},
"暂停->退出" : {

},
"来自" : {

Expand Down Expand Up @@ -9096,6 +9133,9 @@
},
"编辑" : {

},
"行为" : {

},
"要使用动态小尾巴吗?" : {
"localizations" : {
Expand Down Expand Up @@ -9235,6 +9275,12 @@
},
"输入错误" : {

},
"退出" : {

},
"退出 App" : {

},
"选择图片" : {
"localizations" : {
Expand Down
13 changes: 12 additions & 1 deletion MeowBili/Others/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
}
}
Expand Down
53 changes: 51 additions & 2 deletions MeowBili/Video/VideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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?
Expand Down Expand Up @@ -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)
}
Expand All @@ -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")
})
}
}
Expand Down

0 comments on commit 810719e

Please sign in to comment.