Skip to content

Commit

Permalink
Wrap a viewController around the THEOplayerView
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanhaevre authored and tvanlaerhoven committed Nov 14, 2024
1 parent 3548bf1 commit a752eb8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/THEOplayerRCTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class THEOplayerRCTView: UIView {
public private(set) var player: THEOplayer?
public private(set) var mainEventHandler: THEOplayerRCTMainEventHandler
public private(set) var broadcastEventHandler: THEOplayerRCTBroadcastEventHandler
let theoPlayerViewController = UIViewController()
var textTrackEventHandler: THEOplayerRCTTextTrackEventHandler
var mediaTrackEventHandler: THEOplayerRCTMediaTrackEventHandler
var metadataTrackEventHandler: THEOplayerRCTSideloadedMetadataTrackEventHandler
Expand Down Expand Up @@ -76,6 +77,14 @@ public class THEOplayerRCTView: UIView {
if let player = self.player {
player.frame = self.frame
player.autoresizingMask = [.flexibleBottomMargin, .flexibleHeight, .flexibleLeftMargin, .flexibleRightMargin, .flexibleTopMargin, .flexibleWidth]

// wrap theoPlayerViewController around the view
if theoPlayerViewController.parent == nil,
let parentViewController = self.findViewController() {
parentViewController.addChild(self.theoPlayerViewController)
self.theoPlayerViewController.didMove(toParent: parentViewController)
self.theoPlayerViewController.view = self
}
}
}

Expand Down

0 comments on commit a752eb8

Please sign in to comment.