CNLiveZFPlayerControlView.swift 2.33 KB
//
//  CNLiveZFPlayerControlView.swift
//  metaCode
//
//  Created by zx on 2025/2/27.
//

import Foundation
import ZFPlayer
class CNLiveZFPlayerControlView:ZFPlayerControlView{
   
    lazy var beiSuBtn: UIButton = {
        let  closeBtn = UIButton(type: .custom)
        closeBtn.setTitle("倍速", for: .normal)
        closeBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
        closeBtn.titleLabel?.font = Font_10
        closeBtn.addTarget(self, action: #selector(beiSuBtnAction), for: .touchUpInside)
        closeBtn.backgroundColor = .clear
        return closeBtn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI(){
        self.landScapeControlView.bottomToolView.addSubview(self.beiSuBtn)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let min_margin = 9.0
        let min_w = 62.0
        let min_x = CGFloat(self.landScapeControlView.bottomToolView.width) - min_w - ((isiPhoneXSeries && UIApplication.shared.statusBarOrientation.isLandscape) ? 44.0: min_margin)
        let min_y = 0.0
        let min_h = 30.0
        self.landScapeControlView.totalTimeLabel.frame = CGRect(x: min_x-100, y: min_y, width: min_w, height: min_h)
        self.landScapeControlView.totalTimeLabel.centerY = self.landScapeControlView.playOrPauseBtn.centerY
        let min_x1 = self.landScapeControlView.currentTimeLabel.right + 4.0
        let min_y1 = 0.0
        let min_w1 = self.landScapeControlView.totalTimeLabel.left - min_x1 - 4
        let min_h1 = 30.0
        self.landScapeControlView.slider.frame = CGRect(x: min_x1, y: min_y1, width: min_w1, height: min_h1)
        self.landScapeControlView.slider.centerY = self.landScapeControlView.playOrPauseBtn.centerY
        
        self.beiSuBtn.frame = CGRect(x: self.landScapeControlView.totalTimeLabel.right + 10.0, y: 0, width: 40, height: min_h1)
        self.beiSuBtn.centerY = self.landScapeControlView.slider.centerY
//        print("totalTimeLabel:\n \(self.landScapeControlView.totalTimeLabel)")
//        print("slider:\n \(self.landScapeControlView.slider)")
//        print("xuanjiBtn:\n \(self.xuanjiBtn)")

    }
    
    @objc func beiSuBtnAction(){
        print("beiSuBtn")
    }
}