mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 09:41:02 +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) {
|
||||
Text("settings.other.autoplay-video")
|
||||
}
|
||||
Toggle(isOn: $userPreferences.muteVideo) {
|
||||
Text("settings.other.mute-video")
|
||||
}
|
||||
Toggle(isOn: $userPreferences.showAltTextForMedia) {
|
||||
Text("settings.content.media.show.alt")
|
||||
}
|
||||
|
|
|
@ -1991,7 +1991,7 @@
|
|||
},
|
||||
"ko" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"state" : "translated",
|
||||
"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" : {
|
||||
"localizations" : {
|
||||
"be" : {
|
||||
|
@ -65037,7 +65155,7 @@
|
|||
},
|
||||
"ko" : {
|
||||
"stringUnit" : {
|
||||
"state" : "needs_review",
|
||||
"state" : "translated",
|
||||
"value" : "열람 주의 문구"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -23,6 +23,7 @@ import SwiftUI
|
|||
@AppStorage("app_default_reply_visibility") public var appDefaultReplyVisibility: Models.Visibility = .pub
|
||||
@AppStorage("app_default_posts_sensitive") public var appDefaultPostsSensitive = false
|
||||
@AppStorage("autoplay_video") public var autoPlayVideo = true
|
||||
@AppStorage("mute_video") public var muteVideo = false
|
||||
@AppStorage("always_use_deepl") public var alwaysUseDeepl = false
|
||||
@AppStorage("user_deepl_api_free") public var userDeeplAPIFree = 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 {
|
||||
didSet {
|
||||
storage.alwaysUseDeepl = alwaysUseDeepl
|
||||
|
@ -494,6 +502,7 @@ import SwiftUI
|
|||
maxReplyIndentation = storage.maxReplyIndentation
|
||||
showReplyIndentation = storage.showReplyIndentation
|
||||
showAccountPopover = storage.showAccountPopover
|
||||
muteVideo = storage.muteVideo
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,10 @@ import SwiftUI
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mute(_ mute: Bool) {
|
||||
player?.isMuted = mute
|
||||
}
|
||||
|
||||
func pause() {
|
||||
isPlaying = false
|
||||
|
@ -71,13 +75,22 @@ public struct MediaUIAttachmentVideoView: View {
|
|||
public var body: some View {
|
||||
videoView
|
||||
.onAppear {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.playback)
|
||||
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo,
|
||||
isCompact: isCompact)
|
||||
viewModel.mute(preferences.muteVideo)
|
||||
|
||||
DispatchQueue.global().async {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.playback, options: .duckOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient)
|
||||
viewModel.pause()
|
||||
|
||||
DispatchQueue.global().async {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
if !preferences.autoPlayVideo && !viewModel.isPlaying {
|
||||
|
@ -101,11 +114,13 @@ public struct MediaUIAttachmentVideoView: View {
|
|||
if isCompact || !preferences.autoPlayVideo {
|
||||
viewModel.play()
|
||||
}
|
||||
viewModel.mute(false)
|
||||
}
|
||||
.onDisappear {
|
||||
if isCompact || !preferences.autoPlayVideo {
|
||||
viewModel.pause()
|
||||
}
|
||||
viewModel.mute(preferences.muteVideo)
|
||||
}
|
||||
}
|
||||
.cornerRadius(4)
|
||||
|
|
|
@ -30,6 +30,7 @@ extension StatusEditor {
|
|||
}
|
||||
}
|
||||
.scrollPosition(id: $scrollID, anchor: .trailing)
|
||||
.scrollClipDisabled()
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
.frame(height: count > 0 ? containerHeight : 0)
|
||||
.animation(.spring(duration: 0.3), value: count)
|
||||
|
|
Loading…
Reference in a new issue