Skip to content
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

开启屏幕锁定后观看横屏视频,点击倍速画面会转回竖屏 #580

Open
sunzongzheng opened this issue Oct 12, 2023 · 9 comments

Comments

@sunzongzheng
Copy link

Demo项目中可以复现,如果不锁定屏幕&横屏观看就没有问题

auto-rotate.mp4
@kingslay
Copy link
Owner

这个应该是用了UIMenu 才会有这个问题。你可以换成不用UIMenu,

@sunzongzheng
Copy link
Author

sunzongzheng commented Oct 19, 2023

这个应该是用了UIMenu 才会有这个问题。你可以换成不用UIMenu,

试了下用UIAlertController也会,能提供一个示例吗

1-2.mp4

我是直接改的Demo仓库里的RootViewController

private class TableViewCell: UITableViewCell {
    public let vodListButton = UIButton()
    #if os(iOS)
    fileprivate let playerView = IOSVideoPlayerView()
    #else
    fileprivate let playerView = CustomVideoPlayerView()
    #endif
    override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.addSubview(playerView)
        playerView.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            contentView.heightAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.65),
            playerView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 5),
            playerView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
            playerView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
            playerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
        ])

        vodListButton.tintColor = .white
        if let vodListButton = vodListButton as? UIButton {
          vodListButton.setImage(UIImage(systemName: "list.and.film"), for: .normal)
          vodListButton.setImage(UIImage(systemName: "list.and.film"), for: .selected)
        }

        vodListButton.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            vodListButton.widthAnchor.constraint(equalToConstant: 30),
        ])
        playerView.toolBar.addArrangedSubview(vodListButton)
        vodListButton.addTarget(self, action: #selector(presentAlert), for: .touchUpInside)
    }

    @objc func presentAlert() {
        let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)
        alertController.addAction(UIAlertAction(title: "OK", style: .default))
        var topController = UIApplication.shared.keyWindow?.rootViewController
        while let presentedViewController = topController?.presentedViewController {
            topController = presentedViewController
        }
        topController?.present(alertController, animated: true, completion: nil)
    }

    @available(*, unavailable)
    required init?(coder _: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

@charsdavy
Copy link

可以关闭自动旋转的支持吗?

@kingslay
Copy link
Owner

你手机的锁定屏幕应该是打开的吧。所以这个走的应该是强制旋转,而不是自动旋转。

@charsdavy
Copy link

你手机的锁定屏幕应该是打开的吧。所以这个走的应该是强制旋转,而不是自动旋转。

可以在我手机屏幕锁定开关未开启的状态下,关闭KSPlayer的自动旋转吗?即我手动旋转手机,KSPlayer不自动响应旋转。

@kingslay
Copy link
Owner

这个应该是可以的。

@charsdavy
Copy link

看你的文档说了支持自动旋转,但是代码中没看到哪个配置可以控制这个能力。

@Kimentanm
Copy link
Sponsor Contributor

看你的文档说了支持自动旋转,但是代码中没看到哪个配置可以控制这个能力。

KSOptions.supportedInterfaceOrientations
用这个可以控制

@charsdavy
Copy link

那需要实时动态调整吗?不然如果只给了portrait,那不是不能手动旋转了?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants