diff --git a/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift b/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift index 57caf5f9..d4a7599e 100644 --- a/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift @@ -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") } diff --git a/IceCubesApp/Resources/Localization/Localizable.xcstrings b/IceCubesApp/Resources/Localization/Localizable.xcstrings index 9f7a98f0..82661ec3 100644 --- a/IceCubesApp/Resources/Localization/Localizable.xcstrings +++ b/IceCubesApp/Resources/Localization/Localizable.xcstrings @@ -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" : "열람 주의 문구" } }, diff --git a/Packages/Env/Sources/Env/UserPreferences.swift b/Packages/Env/Sources/Env/UserPreferences.swift index f4176616..ac173623 100644 --- a/Packages/Env/Sources/Env/UserPreferences.swift +++ b/Packages/Env/Sources/Env/UserPreferences.swift @@ -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 } } diff --git a/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentVideoView.swift b/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentVideoView.swift index a7e12ac9..bfe2c19a 100644 --- a/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentVideoView.swift +++ b/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentVideoView.swift @@ -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) diff --git a/Packages/StatusKit/Sources/StatusKit/Editor/Components/MediaView.swift b/Packages/StatusKit/Sources/StatusKit/Editor/Components/MediaView.swift index 869c078d..96dfab5c 100644 --- a/Packages/StatusKit/Sources/StatusKit/Editor/Components/MediaView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Editor/Components/MediaView.swift @@ -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)