jsonwang 3 år sedan
förälder
incheckning
311c65f1c2

+ 26 - 6
BFFramework/Classes/BFModules/BFUtility/PQSingletoVideoPlayer.swift

@@ -13,7 +13,7 @@ public class PQSingletoVideoPlayer: NSObject {
     public static let shared = PQSingletoVideoPlayer()
     public var isPlayEnd: Bool = false // 是否已播放完成
     public var isRealPlay: Bool = false // 是否已真实播放
-    public  var isSemiRealPlay: Bool = false // 是否已播放到十秒
+    public var isSemiRealPlay: Bool = false // 是否已播放到十秒
     public var isPlayBegin: Bool = false // 是否已缓冲完成开始播放
     public var isFirstFrame: Bool = false // 是否已显示第一帧加载完成
     public var isPlayerError: Bool = false // 是否播放失败
@@ -40,6 +40,10 @@ public class PQSingletoVideoPlayer: NSObject {
         return player
     }()
 
+    /// 配置播放器
+    /// - Parameters:
+    ///   - videoData: <#videoData description#>
+    ///   - controllerView: <#controllerView description#>
     public func configPlyer(videoData: PQVideoListModel, controllerView: UIView) {
         isPlayEnd = false
         isRealPlay = false
@@ -48,10 +52,8 @@ public class PQSingletoVideoPlayer: NSObject {
         isFirstFrame = false
         isPlayerError = false
         loadingTime = Date().timeIntervalSince1970 * 1000
-
         player.stopPlay()
         player.removeVideoWidget()
-
         player.setupVideoWidget(controllerView, insert: 0)
         player.enableHWAcceleration = true
         playControllerView = controllerView
@@ -70,13 +72,12 @@ public class PQSingletoVideoPlayer: NSObject {
         }
         playId = getUniqueId(desc: "playId")
         BFLog(message: "\(String(describing: videoData.title)) 开始播放 \(videoData.videoPath ?? "")")
-        player.startPlay(videoData.videoPath)
-
         if PQSingletoMemoryUtil.shared.playCount < 4 {
             PQSingletoMemoryUtil.shared.playCount = PQSingletoMemoryUtil.shared.playCount + 1
         }
     }
 
+    /// 重制播放
     public func resetPlayer() {
         if playControllerView != nil {
             player.removeVideoWidget()
@@ -94,18 +95,31 @@ public class PQSingletoVideoPlayer: NSObject {
                 player.setStartTime(progress)
             }
             playId = getUniqueId(desc: "playId")
-            player.startPlay(playVideoData!.videoPath)
+            // 开始播放
+            startPlayr()
         }
     }
 
+    /// 开始播放
+    public func startPlayr() {
+        BFLog(message: "开始播放 \(playVideoData?.videoPath ?? "")")
+        if isValidURL(url: playVideoData?.videoPath) {
+            player.startPlay(playVideoData?.videoPath)
+        }
+    }
+
+    /// 暂停播放
     public func pausePlayer() {
         player.pause()
     }
 
+    /// 继续播放
     public func resumePlayer() {
         player.resume()
     }
 
+    /// 停止播放
+    /// - Parameter isRemove: 是否移除载体视图
     public func stopPlayer(isRemove: Bool = true) {
         player.stopPlay()
         if isRemove {
@@ -114,6 +128,12 @@ public class PQSingletoVideoPlayer: NSObject {
             playVideoData = nil
         }
     }
+    
+    /// seek
+    /// - Parameter time: <#time description#>
+    public func seek(time:Float){
+        player.seek(time)
+    }
 
     override private init() {
         super.init()

+ 17 - 17
BFFramework/Classes/Utils/PQThirdPlatformUtil.swift

@@ -11,22 +11,20 @@ import UIKit
 import UserNotifications
 import WechatOpenSDK
 
-
-
 // MARK: - Bugly初始化工具类
+
 public class PQSingletoBuglyUtil: NSObject {
     public static let shared = PQSingletoBuglyUtil()
-    
-    public func registerBugly(appID:String) {
- 
-         let versionName = "\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] ?? "1.0.0")"
-        
+
+    public func registerBugly(appID: String) {
+        let versionName = "\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] ?? "1.0.0")"
+
         // 注册bugly
         let buglyConfig = BuglyConfig()
         buglyConfig.reportLogLevel = .warn
         #if DEBUG
             buglyConfig.version = versionName + ".6666"
-          
+
         #else
             if PQENVUtil.shared.envMode == .ENVModeOnline {
                 buglyConfig.version = versionName + "." + versionCode
@@ -47,6 +45,7 @@ public class PQSingletoBuglyUtil: NSObject {
 }
 
 // MARK: - 微信相关工具类
+
 // 初始化微信要使用的参数 e.g.
 /*
      let state: String = "com.piaoquan.pqspeed"
@@ -62,6 +61,7 @@ public class WXApiInfo: NSObject {
     public var universalLink: String = ""
     public var scope = ""
 }
+
 public class PQSingletoWXApiUtil: NSObject {
     public static let shared = PQSingletoWXApiUtil()
     var openId: String? // openID
@@ -133,7 +133,7 @@ public class PQSingletoWXApiUtil: NSObject {
         let message = WXMediaMessage()
         message.title = title ?? ""
         message.description = description ?? ""
- 
+
         ImageDownloader.default.downloadImage(with: URL(string: imageUrl ?? "")!, options: nil) { result in
             switch result {
             case let .success(imageResult):
@@ -142,24 +142,24 @@ public class PQSingletoWXApiUtil: NSObject {
                     let wxMiniObject = WXMiniProgramObject()
                     wxMiniObject.miniProgramType = PQENVUtil.shared.envMode == .ENVModeOnline ? .release : .test
                     wxMiniObject.userName = shareWeappRawId ?? cShareWeappRawId
-                    var preParams: String = ""
-                    var page: String = ""
+                    var homePagePath: String = ""
+                    var targetPagePath: String = ""
                     var isRhythmVideo = 0
                     if type == 3 {
-                        preParams = "package-point/show/show"
-                        page = "pages/post/post"
+                        homePagePath = "pages/post/post"
+                        targetPagePath = "package-point/show/show"
                         isRhythmVideo = 1
                     } else {
-                        preParams = "user-videos"
-                        page = "pages/category"
+                        homePagePath = "pages/category"
+                        targetPagePath = "user-videos"
                         isRhythmVideo = 0
                     }
-                    var params = (preParams + "?id=\(videoId)&tp=share&rootPageSource=\(pageSource.rawValue)&shareDepth=1&rootLaunchShareId=\(shareId)&parentShareId=\(shareId)&shareId=\(shareId)&shareAppType=13&mid=\(getMachineCode())&su=\(BFLoginUserInfo.shared.uid)&isRhythmVideo=\(isRhythmVideo)").addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
+                    var params = (targetPagePath + "?id=\(videoId)&tp=share&rootPageSource=\(pageSource.rawValue)&shareDepth=1&rootLaunchShareId=\(shareId)&parentShareId=\(shareId)&shareId=\(shareId)&shareAppType=\(PQBFConfig.shared.appType)&mid=\(getMachineCode())&su=\(BFLoginUserInfo.shared.uid)&isRhythmVideo=\(isRhythmVideo)").addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
                     ["/", "=", "?", "&"].forEach { char in
                         let custom = CharacterSet(charactersIn: char).inverted
                         params = params?.addingPercentEncoding(withAllowedCharacters: custom) ?? ""
                     }
-                    wxMiniObject.path = "\(page)?jumpPage=" + (params ?? "")
+                    wxMiniObject.path = "\(homePagePath)?jumpPage=" + (params ?? "")
                     wxMiniObject.webpageUrl = "https://piaoquan.yishihui.com/"
                     wxMiniObject.hdImageData = message.thumbData
                     message.mediaObject = wxMiniObject