| | |
| | | |
| | | import UIKit |
| | | import JQTools |
| | | import AVKit |
| | | import RxSwift |
| | | |
| | | class VideoView: UIView { |
| | | |
| | | override init(frame: CGRect) { |
| | | super.init(frame: frame) |
| | | backgroundColor = .jq_randomColor |
| | | private var url:String? |
| | | private var disposeBag = DisposeBag() |
| | | |
| | | private lazy var player: CLPlayer = { |
| | | let p = CLPlayer(frame: .zero) { config in |
| | | config.topBarHiddenStyle = .always |
| | | config.isHiddenMorePanel = true |
| | | config.image.max = UIImage(named: "video_max") |
| | | config.image.min = UIImage(named: "video_min") |
| | | config.image.pause = UIImage(named: "video_pause") |
| | | config.image.play = UIImage(named: "video_play") |
| | | config.color.progressFinished = UIColor(hexStr: "#B7DC90") |
| | | config.color.progress = .white |
| | | config.color.progressBuffer = UIColor(hexStr: "#B7DC90").withAlphaComponent(0.75) |
| | | config.image.thumb = UIImage.jq_image(color: UIColor(hexStr: "#B7DC90"), size: CGSize(width: 6.5, height: 6.5), corners: .allCorners, radius: 3.25) |
| | | } |
| | | return p |
| | | }() |
| | | |
| | | required init(url:String) { |
| | | super.init(frame: .zero) |
| | | self.url = url |
| | | if let Url = URL(string: url){ |
| | | player.url = Url |
| | | addSubview(player) |
| | | player.delegate = self |
| | | player.snp.makeConstraints { make in |
| | | make.edges.equalToSuperview() |
| | | } |
| | | player.play() |
| | | } |
| | | } |
| | | |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | } |
| | | |
| | | extension VideoView:CLPlayerDelegate{ |
| | | |
| | | } |