-
-
Notifications
You must be signed in to change notification settings - Fork 361
fix(session-replay): Add masking for AVPlayerView #5910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
29e3aec
fix(session-replay): Add masking for AVPlayerView
philprime d172b03
update changelog
philprime e8ab3c7
update unit tests
philprime d8d12c4
Merge remote-tracking branch 'origin/main' into philprime/sr-video-vi…
philprime 078d55a
Merge remote-tracking branch 'origin/main' into philprime/sr-video-vi…
philprime 61c7838
WIP
philprime 1929bc8
Merge remote-tracking branch 'origin/main' into philprime/sr-video-vi…
philprime d050c4f
fixed tests
philprime 1dee75b
Merge remote-tracking branch 'origin/main' into philprime/sr-video-vi…
philprime d5ce94f
fixed linting error
philprime 904cfb6
Merge branch 'main' into philprime/sr-video-view-masking
philprime 73ff114
Merge remote-tracking branch 'origin/main' into philprime/sr-video-vi…
philprime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
63 changes: 63 additions & 0 deletions
63
Samples/iOS-Swift/iOS-Swift/ViewControllers/SentryVideoViewController.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import AVKit | ||
import UIKit | ||
|
||
/// Video view controller for displaying video using the ``AVKit`` framework. | ||
/// | ||
/// See the expo-video video view for reference: | ||
/// https://github.com/expo/expo/blob/sdk-53/packages/expo-video/ios/VideoView.swift | ||
class SentryVideoViewController: UIViewController { | ||
lazy var playerViewController = AVPlayerViewController() | ||
|
||
weak var player: AVPlayer? { | ||
didSet { | ||
playerViewController.player = player | ||
} | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setupPlayerUI() | ||
setupPlayer() | ||
} | ||
|
||
override func viewWillAppear(_ animated: Bool) { | ||
super.viewWillAppear(animated) | ||
|
||
// Start playing the video when the view appears. | ||
player?.play() | ||
} | ||
|
||
func setupPlayerUI() { | ||
// Use a distinct color to clearly indicate when the video content not being displayed. | ||
playerViewController.view.backgroundColor = .systemOrange | ||
|
||
// Disable updates to the Now Playing Info Center, to increase isolation of app to global system state. | ||
playerViewController.updatesNowPlayingInfoCenter = false | ||
|
||
// Reference for the correct life cycle calls: | ||
// https://developer.apple.com/documentation/uikit/creating-a-custom-container-view-controller#Add-a-child-view-controller-programmatically-to-your-content | ||
addChild(playerViewController) | ||
view.addSubview(playerViewController.view) | ||
|
||
playerViewController.view.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
playerViewController.view.topAnchor.constraint(greaterThanOrEqualTo: view.safeAreaLayoutGuide.topAnchor), | ||
playerViewController.view.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor), | ||
|
||
playerViewController.view.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor), | ||
playerViewController.view.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor) | ||
]) | ||
|
||
playerViewController.didMove(toParent: self) | ||
} | ||
|
||
func setupPlayer() { | ||
guard let videoUrl = Bundle.main.url(forResource: "Sample", withExtension: "mp4") else { | ||
preconditionFailure("Sample video not found in main bundle") | ||
} | ||
let player = AVPlayer(url: videoUrl) | ||
player.isMuted = true | ||
self.player = player | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.