cache.lan_form = from
cache.lan_to = to
SubTitleCache.shared.save(cache)
- restart()
+ if sdk.recording {
+ restart()
+ }
}
}
tableView.do { v in
object: nil
)
NotificationManager.add(self, selector: #selector(deviceChange), forName: .deviceValidChange)
+ NotificationCenter.default.addObserver(self, selector: #selector(orientationAction), name: UIDevice.orientationDidChangeNotification, object: nil)
+ }
+ @objc func orientationAction() {
+ if UIDevice.current.orientation.isLandscape {
+ print("画中画处于横屏状态")
+
+ } else {
+ print("画中画处于竖屏状态")
+ }
+// pipManager.reset(supperView: self.navigationController!.view)
}
@objc func deviceChange(){
if CCBleManager.shared.isConneted{
let cache = SubTitleCache.shared.get()
languageItem.leftLabel.language = cache.lan_form
languageItem.rightLabel.language = cache.lan_to
- restart()
+ if sdk.recording {
+ restart()
+ }
}
vc.soureChanged = {[weak self] in
guard let self = self else{return}
- restart()
+ if sdk.recording {
+ restart()
+ }
}
vc.showTypeChanged = {[weak self] in
guard let self = self else{return}
}
@objc private func appDidEnterBackground(_ notification: Notification) {
- if sdk.recording {
-// pipManager.startPictureInPicture()
- }
+
}
@objc private func appWillEnterForeground(_ notification: Notification) {
//
// Created by liangshi on 2026/4/2.
//
+// 自动开启录音
+// 横屏没有适配
import UIKit
import AVKit
private var contentView = PipContentView()
weak var delegate:PipManagerDelegate?
var playerLayer: AVPlayerLayer?
+ var superView:UIView = UIView()
+
+ override init() {
+
+ }
func dissmiss(){
if let pip = pipController{
}
func reset(supperView:UIView){
+ self.superView = supperView
var isStart = false
if let pip = pipController{
isStart = pip.isPictureInPictureActive
playerLayer?.removeFromSuperlayer()
}
+
+
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback, options: [.allowAirPlay, .allowBluetooth])
try AVAudioSession.sharedInstance().setActive(true)
Logger.debug("Audio session setup failed: \(error)")
}
-
+ let isLandscape = UIDevice.current.orientation.isLandscape
+// let width = isLandscape ? kScreenHei - 20: kScreenWid - 20
+ let width = kScreenWid - 20
if SubTitleCache.shared.get().showType == .all {
- playerLayer = AVPlayerLayer(player: AVPlayer(url: Bundle.main.url(forResource: "shu2", withExtension: "mp4")!))
- playerLayer?.frame = CGRect(x: 10, y: kScreenHei, width: kScreenWid - 20, height: 80)
- contentView.frame = CGRectMake(0, 0, kScreenWid - 20, 80)
+ playerLayer = AVPlayerLayer(player: AVPlayer(url: Bundle.main.url(forResource: isLandscape ? "heng2":"shu2", withExtension: "mp4")!))
+ playerLayer?.frame = CGRect(x: 10, y: kScreenHei, width: width, height: 80)
+ contentView.frame = CGRectMake(0, 0, width, 80)
contentView.reset()
}
else{
- playerLayer = AVPlayerLayer(player: AVPlayer(url: Bundle.main.url(forResource: "shu1", withExtension: "mp4")!))
- playerLayer?.frame = CGRect(x: 10, y: kScreenHei, width: kScreenWid - 20, height: 40)
- contentView.frame = CGRectMake(0, 0, kScreenWid - 20, 40)
+ playerLayer = AVPlayerLayer(player: AVPlayer(url: Bundle.main.url(forResource: isLandscape ? "heng1":"shu1", withExtension: "mp4")!))
+ playerLayer?.frame = CGRect(x: 10, y: kScreenHei, width: width, height: 40)
+ contentView.frame = CGRectMake(0, 0, width, 40)
contentView.reset()
}