CNLiveCommonManager.swift
2.14 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
//
// CNLiveCommonManager.swift
// metaCode
//
// Created by zx on 2023/11/29.
//
import Foundation
import CNLiveRequestBastKit
typealias getTimeWithResultBlock = (_ networkTimestamp:Double) -> Void
class CNLiveCommonManager: NSObject{
//单例类
static let shared = CNLiveCommonManager()
/// 跳转播放器
/// @param playURL 播放URL
/// @param coverImage 封面图
/// @param coverImageUrl 封面图url
func skipPlayerVCWithPlayURL(playURL:URL,coverImage:UIImage?,coverImageUrl:String?){
let vc = CNLivePlayerViewController()
vc.setPlayUrl(playUrl: playURL, isLive: false)
vc.coverImageUrl = coverImageUrl
navigationViewController().pushViewController(vc, animated: pushAnimated)
// currentViewController()?.navigationController?.pushViewController(vc, animated: pushAnimated)
}
/**
获取网络时间
*/
func postGetTimeWithResult(resultBlock:@escaping getTimeWithResultBlock){
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
let custom_param = NSMutableDictionary()
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId")
custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey_wjj, forKey: "appKey")
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/Api/Index3/get_time", param: nil, cacheType: .networkOnly) { task, result, error in
if error == nil{
let res = (result as! NSDictionary)
let allKeys = res.allKeys as NSArray
var networkTimestamp:Double = 0
if allKeys.contains("time"){
networkTimestamp = (res["time"] as! NSString).doubleValue
}
resultBlock(networkTimestamp)
}else{
let date = Date()
let timestamp = date.timeIntervalSince1970
resultBlock(timestamp)
}
}
}
}