|
@@ -11,6 +11,7 @@ import BFAnalyzeKit
|
|
|
import BFCommonKit
|
|
|
import BFUploadKit
|
|
|
import UIKit
|
|
|
+import CryptoSwift
|
|
|
|
|
|
public class PQSingletoVideoPlayer: NSObject {
|
|
|
public static let shared = PQSingletoVideoPlayer()
|
|
@@ -139,10 +140,59 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
/// 开始播放
|
|
|
public func startPlayr() {
|
|
|
BFLog(message: "开始播放 \(playVideoData?.videoPath ?? "")")
|
|
|
- if isValidURL(url: playVideoData?.videoPath) {
|
|
|
- player.startPlay(playVideoData?.videoPath)
|
|
|
+ // 2023-08-28 增加加密地址,修改逻辑
|
|
|
+// if isValidURL(url: playVideoData?.videoPath) {
|
|
|
+// player.startPlay(playVideoData?.videoPath)
|
|
|
+// }
|
|
|
+ if let realPath = getRealVideoPath(url: playVideoData?.videoPath) {
|
|
|
+ player.startPlay(realPath)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public func getRealVideoPath(url: String?) -> String?{
|
|
|
+ var tmpUrl = url
|
|
|
+ if tmpUrl == nil || (tmpUrl?.count ?? 0) <= 4 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ if !(tmpUrl!.hasPrefix("http")) && !(tmpUrl!.hasPrefix("https")) {
|
|
|
+ do {
|
|
|
+ let encrytoData = Data(base64Encoded: tmpUrl!, options: .ignoreUnknownCharacters) ?? Data()
|
|
|
+ let key: String = "pqv2jo0lon2vid2t"
|
|
|
+ let decryptedString = try aes128Decrypt(data: encrytoData, key: key)
|
|
|
+ print("Decrypted String: \(decryptedString)")
|
|
|
+ return decryptedString
|
|
|
+ }catch {
|
|
|
+ print("Decryption error: \(error)")
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return url
|
|
|
+ }
|
|
|
+
|
|
|
+ func aes128Decrypt(data: Data, key: String) throws -> String {
|
|
|
+ let keyData = Array(key.utf8)
|
|
|
+
|
|
|
+ do {
|
|
|
+ let aes = try AES(key: keyData, blockMode: ECB(), padding: .pkcs7)
|
|
|
+ let decrypted = try aes.decrypt(data.bytes)
|
|
|
+ let decryptedData = Data(decrypted)
|
|
|
+
|
|
|
+ if let decryptedString = String(data: decryptedData, encoding: .utf8) {
|
|
|
+ return decryptedString
|
|
|
+ } else {
|
|
|
+ throw CryptoError.decryptionFailed
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ throw CryptoError.decryptionFailed
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ enum CryptoError: Error {
|
|
|
+ case decryptionFailed
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/// 暂停播放
|
|
|
public func pausePlayer() {
|