|
|
@@ -6,6 +6,7 @@ final class RedditWebViewStore {
|
|
|
static let shared = RedditWebViewStore()
|
|
|
|
|
|
private(set) var container: RedditWebViewContainer?
|
|
|
+ private var isMediaPlaybackSuspended = false
|
|
|
|
|
|
private init() {}
|
|
|
|
|
|
@@ -19,4 +20,16 @@ final class RedditWebViewStore {
|
|
|
container = newContainer
|
|
|
return newContainer
|
|
|
}
|
|
|
+
|
|
|
+ func suspendMediaPlaybackForWindowMinimize() {
|
|
|
+ guard let webView = container?.webView, !isMediaPlaybackSuspended else { return }
|
|
|
+ isMediaPlaybackSuspended = true
|
|
|
+ webView.setAllMediaPlaybackSuspended(true, completionHandler: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ func resumeMediaPlaybackAfterWindowDeminiaturize() {
|
|
|
+ guard let webView = container?.webView, isMediaPlaybackSuspended else { return }
|
|
|
+ isMediaPlaybackSuspended = false
|
|
|
+ webView.setAllMediaPlaybackSuspended(false, completionHandler: nil)
|
|
|
+ }
|
|
|
}
|