-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathOSIABWebViewConfigurationModel.swift
More file actions
41 lines (38 loc) · 2.38 KB
/
OSIABWebViewConfigurationModel.swift
File metadata and controls
41 lines (38 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import WebKit
/// Collection of properties with which to initialize the WebView.
struct OSIABWebViewConfigurationModel {
/// Indicates if HTML5 audio or video should be prevented from being autoplayed.
private let mediaTypesRequiringUserActionForPlayback: WKAudiovisualMediaTypes
/// Indicates if scaling through a meta tag should be prevented.
private let ignoresViewportScaleLimits: Bool
/// Indicates if in-line HTML5 media playback should be enabled.
private let allowsInlineMediaPlayback: Bool
/// Indicates if the rendering should wait until all new view content is received.
private let suppressesIncrementalRendering: Bool
/// Constructor method.
/// - Parameters:
/// - mediaTypesRequiringUserActionForPlayback: Indicates if HTML5 audio or video should be prevented from being autoplayed. Defaults to nothing being autoplayed.
/// - ignoresViewportScaleLimits: Indicates if scaling through a meta tag should be prevented. Defaults to `false`.
/// - allowsInlineMediaPlayback: Indicates if in-line HTML5 media playback should be enabled. Defaults to `false`
/// - suppressesIncrementalRendering: Indicates if the rendering should wait until all new view content is received. Defaults to `false`.
init(
_ mediaTypesRequiringUserActionForPlayback: WKAudiovisualMediaTypes = [],
_ ignoresViewportScaleLimits: Bool = false,
_ allowsInlineMediaPlayback: Bool = false,
_ suppressesIncrementalRendering: Bool = false
) {
self.mediaTypesRequiringUserActionForPlayback = mediaTypesRequiringUserActionForPlayback
self.ignoresViewportScaleLimits = ignoresViewportScaleLimits
self.allowsInlineMediaPlayback = allowsInlineMediaPlayback
self.suppressesIncrementalRendering = suppressesIncrementalRendering
}
/// Creates a `WKWebViewConfiguration` object with all the model's properties.
func toWebViewConfiguration() -> WKWebViewConfiguration {
let configuration = WKWebViewConfiguration()
configuration.mediaTypesRequiringUserActionForPlayback = mediaTypesRequiringUserActionForPlayback
configuration.ignoresViewportScaleLimits = ignoresViewportScaleLimits
configuration.allowsInlineMediaPlayback = allowsInlineMediaPlayback
configuration.suppressesIncrementalRendering = suppressesIncrementalRendering
return configuration
}
}