From: liangzhenying <867174124@qq.com> Date: Tue, 7 Apr 2026 07:49:27 +0000 (+0800) Subject: 修复字符字幕翻译切换语言自动 开启bug X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=fc9a6c1763710bd2918f89bba597bef808d9f7be;p=mirrors%2FShenYin.git 修复字符字幕翻译切换语言自动 开启bug --- diff --git a/ShenYin/ShenYin/Channel/PLAYBOY/Channel/UI/PbSubTitleVC.swift b/ShenYin/ShenYin/Channel/PLAYBOY/Channel/UI/PbSubTitleVC.swift index ea4c318..95d402f 100644 --- a/ShenYin/ShenYin/Channel/PLAYBOY/Channel/UI/PbSubTitleVC.swift +++ b/ShenYin/ShenYin/Channel/PLAYBOY/Channel/UI/PbSubTitleVC.swift @@ -68,7 +68,9 @@ class PbSubTitleVC: BaseVC { cache.lan_form = from cache.lan_to = to SubTitleCache.shared.save(cache) - restart() + if sdk.recording { + restart() + } } } tableView.do { v in @@ -119,6 +121,16 @@ class PbSubTitleVC: BaseVC { 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{ @@ -139,11 +151,15 @@ class PbSubTitleVC: BaseVC { 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} @@ -157,9 +173,7 @@ class PbSubTitleVC: BaseVC { } @objc private func appDidEnterBackground(_ notification: Notification) { - if sdk.recording { -// pipManager.startPictureInPicture() - } + } @objc private func appWillEnterForeground(_ notification: Notification) { diff --git a/ShenYin/ShenYin/Resource/heng1.mp4 b/ShenYin/ShenYin/Resource/heng1.mp4 new file mode 100644 index 0000000..996ffc3 Binary files /dev/null and b/ShenYin/ShenYin/Resource/heng1.mp4 differ diff --git a/ShenYin/ShenYin/Resource/heng2.mp4 b/ShenYin/ShenYin/Resource/heng2.mp4 new file mode 100644 index 0000000..93fd006 Binary files /dev/null and b/ShenYin/ShenYin/Resource/heng2.mp4 differ diff --git a/ShenYin/ShenYin/UI/Home/SubTitle/shu1.mp4 b/ShenYin/ShenYin/Resource/shu1.mp4 similarity index 100% rename from ShenYin/ShenYin/UI/Home/SubTitle/shu1.mp4 rename to ShenYin/ShenYin/Resource/shu1.mp4 diff --git a/ShenYin/ShenYin/UI/Home/SubTitle/shu2.mp4 b/ShenYin/ShenYin/Resource/shu2.mp4 similarity index 100% rename from ShenYin/ShenYin/UI/Home/SubTitle/shu2.mp4 rename to ShenYin/ShenYin/Resource/shu2.mp4 diff --git a/ShenYin/ShenYin/UI/Home/SubTitle/PipManager.swift b/ShenYin/ShenYin/UI/Home/SubTitle/PipManager.swift index dd21d79..99bf350 100644 --- a/ShenYin/ShenYin/UI/Home/SubTitle/PipManager.swift +++ b/ShenYin/ShenYin/UI/Home/SubTitle/PipManager.swift @@ -4,6 +4,8 @@ // // Created by liangshi on 2026/4/2. // +// 自动开启录音 +// 横屏没有适配 import UIKit import AVKit @@ -18,6 +20,11 @@ class PipManager: NSObject { private var contentView = PipContentView() weak var delegate:PipManagerDelegate? var playerLayer: AVPlayerLayer? + var superView:UIView = UIView() + + override init() { + + } func dissmiss(){ if let pip = pipController{ @@ -28,6 +35,7 @@ class PipManager: NSObject { } func reset(supperView:UIView){ + self.superView = supperView var isStart = false if let pip = pipController{ isStart = pip.isPictureInPictureActive @@ -36,6 +44,8 @@ class PipManager: NSObject { playerLayer?.removeFromSuperlayer() } + + do { try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback, options: [.allowAirPlay, .allowBluetooth]) try AVAudioSession.sharedInstance().setActive(true) @@ -43,17 +53,19 @@ class PipManager: NSObject { 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() }