杨锴
2024-08-28 4d776ec3b272c40c5d9058af875211811835793f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
//  VoiceView.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/19.
//
 
import UIKit
import JQTools
import AVKit
import RxSwift
 
class VideoView: UIView {
 
                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{
                
}