mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-04-26 18:04:44 +00:00
Add new setting to mute video
This commit is contained in:
parent
7a7066baa4
commit
2c7ca2ca81
5 changed files with 150 additions and 4 deletions
|
@ -28,6 +28,9 @@ struct ContentSettingsView: View {
|
||||||
Toggle(isOn: $userPreferences.autoPlayVideo) {
|
Toggle(isOn: $userPreferences.autoPlayVideo) {
|
||||||
Text("settings.other.autoplay-video")
|
Text("settings.other.autoplay-video")
|
||||||
}
|
}
|
||||||
|
Toggle(isOn: $userPreferences.muteVideo) {
|
||||||
|
Text("settings.other.mute-video")
|
||||||
|
}
|
||||||
Toggle(isOn: $userPreferences.showAltTextForMedia) {
|
Toggle(isOn: $userPreferences.showAltTextForMedia) {
|
||||||
Text("settings.content.media.show.alt")
|
Text("settings.content.media.show.alt")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1991,7 +1991,7 @@
|
||||||
},
|
},
|
||||||
"ko" : {
|
"ko" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "needs_review",
|
"state" : "translated",
|
||||||
"value" : "열람 주의 문구"
|
"value" : "열람 주의 문구"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -48738,6 +48738,124 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"settings.other.mute-video" : {
|
||||||
|
"localizations" : {
|
||||||
|
"be" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ca" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"de" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"en-GB" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eu" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"it" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ja" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ko" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nb" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nl" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pl" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pt-BR" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uk" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hans" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hant" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "needs_review",
|
||||||
|
"value" : "Mute Videos"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"settings.other.social-keyboard" : {
|
"settings.other.social-keyboard" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"be" : {
|
"be" : {
|
||||||
|
@ -65037,7 +65155,7 @@
|
||||||
},
|
},
|
||||||
"ko" : {
|
"ko" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "needs_review",
|
"state" : "translated",
|
||||||
"value" : "열람 주의 문구"
|
"value" : "열람 주의 문구"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,6 +23,7 @@ import SwiftUI
|
||||||
@AppStorage("app_default_reply_visibility") public var appDefaultReplyVisibility: Models.Visibility = .pub
|
@AppStorage("app_default_reply_visibility") public var appDefaultReplyVisibility: Models.Visibility = .pub
|
||||||
@AppStorage("app_default_posts_sensitive") public var appDefaultPostsSensitive = false
|
@AppStorage("app_default_posts_sensitive") public var appDefaultPostsSensitive = false
|
||||||
@AppStorage("autoplay_video") public var autoPlayVideo = true
|
@AppStorage("autoplay_video") public var autoPlayVideo = true
|
||||||
|
@AppStorage("mute_video") public var muteVideo = false
|
||||||
@AppStorage("always_use_deepl") public var alwaysUseDeepl = false
|
@AppStorage("always_use_deepl") public var alwaysUseDeepl = false
|
||||||
@AppStorage("user_deepl_api_free") public var userDeeplAPIFree = true
|
@AppStorage("user_deepl_api_free") public var userDeeplAPIFree = true
|
||||||
@AppStorage("auto_detect_post_language") public var autoDetectPostLanguage = true
|
@AppStorage("auto_detect_post_language") public var autoDetectPostLanguage = true
|
||||||
|
@ -171,6 +172,13 @@ import SwiftUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var muteVideo: Bool {
|
||||||
|
didSet {
|
||||||
|
storage.muteVideo = muteVideo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public var alwaysUseDeepl: Bool {
|
public var alwaysUseDeepl: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
storage.alwaysUseDeepl = alwaysUseDeepl
|
storage.alwaysUseDeepl = alwaysUseDeepl
|
||||||
|
@ -494,6 +502,7 @@ import SwiftUI
|
||||||
maxReplyIndentation = storage.maxReplyIndentation
|
maxReplyIndentation = storage.maxReplyIndentation
|
||||||
showReplyIndentation = storage.showReplyIndentation
|
showReplyIndentation = storage.showReplyIndentation
|
||||||
showAccountPopover = storage.showAccountPopover
|
showAccountPopover = storage.showAccountPopover
|
||||||
|
muteVideo = storage.muteVideo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ import SwiftUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mute(_ mute: Bool) {
|
||||||
|
player?.isMuted = mute
|
||||||
|
}
|
||||||
|
|
||||||
func pause() {
|
func pause() {
|
||||||
isPlaying = false
|
isPlaying = false
|
||||||
|
@ -71,13 +75,22 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
videoView
|
videoView
|
||||||
.onAppear {
|
.onAppear {
|
||||||
try? AVAudioSession.sharedInstance().setCategory(.playback)
|
|
||||||
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo,
|
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo,
|
||||||
isCompact: isCompact)
|
isCompact: isCompact)
|
||||||
|
viewModel.mute(preferences.muteVideo)
|
||||||
|
|
||||||
|
DispatchQueue.global().async {
|
||||||
|
try? AVAudioSession.sharedInstance().setCategory(.playback, options: .duckOthers)
|
||||||
|
try? AVAudioSession.sharedInstance().setActive(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
try? AVAudioSession.sharedInstance().setCategory(.ambient)
|
|
||||||
viewModel.pause()
|
viewModel.pause()
|
||||||
|
|
||||||
|
DispatchQueue.global().async {
|
||||||
|
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||||
|
try? AVAudioSession.sharedInstance().setActive(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if !preferences.autoPlayVideo && !viewModel.isPlaying {
|
if !preferences.autoPlayVideo && !viewModel.isPlaying {
|
||||||
|
@ -101,11 +114,13 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
if isCompact || !preferences.autoPlayVideo {
|
if isCompact || !preferences.autoPlayVideo {
|
||||||
viewModel.play()
|
viewModel.play()
|
||||||
}
|
}
|
||||||
|
viewModel.mute(false)
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
if isCompact || !preferences.autoPlayVideo {
|
if isCompact || !preferences.autoPlayVideo {
|
||||||
viewModel.pause()
|
viewModel.pause()
|
||||||
}
|
}
|
||||||
|
viewModel.mute(preferences.muteVideo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.cornerRadius(4)
|
.cornerRadius(4)
|
||||||
|
|
|
@ -30,6 +30,7 @@ extension StatusEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.scrollPosition(id: $scrollID, anchor: .trailing)
|
.scrollPosition(id: $scrollID, anchor: .trailing)
|
||||||
|
.scrollClipDisabled()
|
||||||
.padding(.horizontal, .layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.frame(height: count > 0 ? containerHeight : 0)
|
.frame(height: count > 0 ? containerHeight : 0)
|
||||||
.animation(.spring(duration: 0.3), value: count)
|
.animation(.spring(duration: 0.3), value: count)
|
||||||
|
|
Loading…
Reference in a new issue