forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVideoView.swift
More file actions
84 lines (70 loc) · 2.1 KB
/
VideoView.swift
File metadata and controls
84 lines (70 loc) · 2.1 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// VideoView.swift
// OpenVideoCall
//
// Created by GongYuhua on 2/14/16.
// Copyright © 2016 Agora. All rights reserved.
//
import Cocoa
protocol NibLoadable {
static var nibName: String? { get }
static func createFromNib(in bundle: Bundle) -> Self?
}
extension NibLoadable where Self: NSView {
static var nibName: String? {
return String(describing: Self.self)
}
static func createFromNib(in bundle: Bundle = Bundle.main) -> Self? {
guard let nibName = nibName else { return nil }
var topLevelArray: NSArray? = nil
bundle.loadNibNamed(NSNib.Name(nibName), owner: self, topLevelObjects: &topLevelArray)
guard let results = topLevelArray else { return nil }
let views = Array<Any>(results).filter { $0 is Self }
return views.last as? Self
}
}
class VideoView: NSView,NibLoadable {
@IBOutlet weak var placeholder: NSTextField!
@IBOutlet weak var videocanvas: NSView!
@IBOutlet weak var infolabel: NSTextField!
@IBOutlet weak var statsLabel:NSTextField!
var uid:UInt? {
didSet {
infolabel.stringValue = uid == nil ? "" : "\(uid!)"
}
}
var audioOnly:Bool = false
enum StreamType {
case local
case remote
func isLocal() -> Bool{
switch self {
case .local: return true
case .remote: return false
}
}
}
var statsInfo:StatisticsInfo? {
didSet{
guard let stats = statsInfo else {return}
statsLabel.stringValue = stats.description(audioOnly: audioOnly)
}
}
var type:StreamType?
override func awakeFromNib() {
super.awakeFromNib()
}
}
class MetalVideoView: NSView,NibLoadable {
@IBOutlet weak var placeholder: NSTextField!
@IBOutlet weak var videocanvas: AgoraMetalRender!
@IBOutlet weak var infolabel: NSTextField!
var uid:UInt? {
didSet {
infolabel.stringValue = uid == nil ? "" : "\(uid!)"
}
}
override func awakeFromNib() {
super.awakeFromNib()
}
}