Skip to content

Commit

Permalink
Added automaticallyAdjustsContentInsets to YouTubePlayer Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenTiigi committed Jun 2, 2022
1 parent 96b831c commit fa70945
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Configuration/YouTubePlayer+Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public extension YouTubePlayer {
/// - Note: This property is excluded from encoding
public var isUserInteractionEnabled: Bool?

/// A Boolean value indicating if safe area insets should be added automatically to content insets
/// - Note: This property is excluded from encoding
public var automaticallyAdjustsContentInsets: Bool?

/// A Boolean value that indicates whether HTML5 videos can play Picture in Picture.
/// - Note: This property is excluded from encoding
public var allowsPictureInPictureMediaPlayback: Bool?
Expand Down Expand Up @@ -97,6 +101,7 @@ public extension YouTubePlayer {
/// Creates a new instance of `YouTubePlayer.Configuration`
public init(
isUserInteractionEnabled: Bool? = nil,
automaticallyAdjustsContentInsets: Bool? = nil,
allowsPictureInPictureMediaPlayback: Bool? = nil,
autoPlay: Bool? = nil,
captionLanguage: String? = nil,
Expand All @@ -118,6 +123,7 @@ public extension YouTubePlayer {
customUserAgent: String? = nil
) {
self.isUserInteractionEnabled = isUserInteractionEnabled
self.automaticallyAdjustsContentInsets = automaticallyAdjustsContentInsets
self.allowsPictureInPictureMediaPlayback = allowsPictureInPictureMediaPlayback
self.autoPlay = autoPlay
self.captionLanguage = captionLanguage
Expand Down
12 changes: 12 additions & 0 deletions Sources/WebView/YouTubePlayerWebView+LoadPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ extension YouTubePlayerWebView {
self.configuration.allowsPictureInPictureMediaPlayback = self.player
.configuration
.allowsPictureInPictureMediaPlayback ?? true
// Update contentInsetAdjustmentBehavior
self.scrollView.contentInsetAdjustmentBehavior = self.player
.configuration
.automaticallyAdjustsContentInsets
.flatMap { $0 ? .automatic : .never }
?? .automatic
#else
// Update automaticallyAdjustsContentInsets
self.enclosingScrollView?.automaticallyAdjustsContentInsets = self.player
.configuration
.automaticallyAdjustsContentInsets
?? true
#endif
// Set custom user agent
self.customUserAgent = self.player.configuration.customUserAgent
Expand Down

0 comments on commit fa70945

Please sign in to comment.