Commit 85e6297c0633ec1f833361be50f68d46ea58fb17
1 parent
44dd5abc
点播页增加显示录屏功能
Showing
2 changed files
with
43 additions
and
1 deletions
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| @@ -182,7 +182,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -182,7 +182,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 182 | view.backgroundColor = .black | 182 | view.backgroundColor = .black |
| 183 | self.view.addSubview(self.whitBgView) | 183 | self.view.addSubview(self.whitBgView) |
| 184 | self.view.addSubview(self.containerView) | 184 | self.view.addSubview(self.containerView) |
| 185 | - | 185 | + |
| 186 | let backBtn = UIButton.backItem(imageName: ("mine_header_icon_white_back"), target: self, action: #selector(ClickBackBtn)) | 186 | let backBtn = UIButton.backItem(imageName: ("mine_header_icon_white_back"), target: self, action: #selector(ClickBackBtn)) |
| 187 | backBtn.frame = CGRect(x: 15, y: KStatusBarHeight, width: backBtn.width, height: backBtn.height) | 187 | backBtn.frame = CGRect(x: 15, y: KStatusBarHeight, width: backBtn.width, height: backBtn.height) |
| 188 | self.view.addSubview(backBtn) | 188 | self.view.addSubview(backBtn) |
| @@ -249,6 +249,15 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -249,6 +249,15 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 249 | name: UIApplication.didBecomeActiveNotification, | 249 | name: UIApplication.didBecomeActiveNotification, |
| 250 | object: nil | 250 | object: nil |
| 251 | ) | 251 | ) |
| 252 | + | ||
| 253 | + //录屏状态实时检测 监听 | ||
| 254 | + NotificationCenter.default.addObserver( | ||
| 255 | + self, | ||
| 256 | + selector: #selector(handleScreenCaptureChange), | ||
| 257 | + name: UIScreen.capturedDidChangeNotification, | ||
| 258 | + object: nil | ||
| 259 | + ) | ||
| 260 | + | ||
| 252 | // 直接关闭手势识别 | 261 | // 直接关闭手势识别 |
| 253 | // self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false | 262 | // self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false |
| 254 | } | 263 | } |
| @@ -261,6 +270,38 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -261,6 +270,38 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 261 | self.player.currentPlayerManager.play() | 270 | self.player.currentPlayerManager.play() |
| 262 | } | 271 | } |
| 263 | } | 272 | } |
| 273 | + // 响应录屏状态变化 | ||
| 274 | + @objc private func handleScreenCaptureChange() { | ||
| 275 | + if UIScreen.main.isCaptured { | ||
| 276 | + showPrivacyProtection() | ||
| 277 | + self.player.allowOrentitaionRotation = false | ||
| 278 | + } else { | ||
| 279 | + hidePrivacyProtection() | ||
| 280 | + self.player.allowOrentitaionRotation = true | ||
| 281 | + } | ||
| 282 | + } | ||
| 283 | + // 显示保护层(模糊效果) | ||
| 284 | + private func showPrivacyProtection() { | ||
| 285 | + let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .regular)) | ||
| 286 | + blurView.frame = view.bounds | ||
| 287 | + view.addSubview(blurView) | ||
| 288 | + | ||
| 289 | + // 显示警告提示 | ||
| 290 | + let alert = UIAlertController( | ||
| 291 | + title: "录屏已开启", | ||
| 292 | + message: "当前功能禁止屏幕录制", | ||
| 293 | + preferredStyle: .alert | ||
| 294 | + ) | ||
| 295 | + present(alert, animated: true) | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + // 移除保护层 | ||
| 299 | + private func hidePrivacyProtection() { | ||
| 300 | + view.subviews | ||
| 301 | + .filter { $0 is UIVisualEffectView } | ||
| 302 | + .forEach { $0.removeFromSuperview() } | ||
| 303 | + dismiss(animated: true) {} | ||
| 304 | + } | ||
| 264 | 305 | ||
| 265 | 306 | ||
| 266 | func configDataArray(){ | 307 | func configDataArray(){ |
metaCode/Classes/Other/AD/CNLiveLaunchAdController.swift
| @@ -30,6 +30,7 @@ class CNLiveLaunchAdController:UIViewController,URLSessionTaskDelegate{ | @@ -30,6 +30,7 @@ class CNLiveLaunchAdController:UIViewController,URLSessionTaskDelegate{ | ||
| 30 | closeBtn.layer.cornerRadius = 16 | 30 | closeBtn.layer.cornerRadius = 16 |
| 31 | closeBtn.layer.masksToBounds = true | 31 | closeBtn.layer.masksToBounds = true |
| 32 | closeBtn.titleLabel?.font = Font_13 | 32 | closeBtn.titleLabel?.font = Font_13 |
| 33 | + closeBtn.setTitleColor(.lightGray, for: .normal) | ||
| 33 | closeBtn.addTarget(self, action: #selector(skipAction), for: .touchUpInside) | 34 | closeBtn.addTarget(self, action: #selector(skipAction), for: .touchUpInside) |
| 34 | closeBtn.contentHorizontalAlignment = .center | 35 | closeBtn.contentHorizontalAlignment = .center |
| 35 | return closeBtn | 36 | return closeBtn |