Procházet zdrojové kódy

1.修改视频播放

wenweiwei před 3 roky
rodič
revize
26255a0655

+ 15 - 6
BFFramework/Classes/Utils/PQSingletoVideoPlayer.swift

@@ -10,7 +10,7 @@
 import UIKit
 
 public class PQSingletoVideoPlayer: NSObject {
-    static public let shared = PQSingletoVideoPlayer()
+    public static let shared = PQSingletoVideoPlayer()
     public var isPlayEnd: Bool = false // 是否已播放完成
     var isRealPlay: Bool = false // 是否已真实播放
     var isSemiRealPlay: Bool = false // 是否已播放到十秒
@@ -18,7 +18,6 @@ public class PQSingletoVideoPlayer: NSObject {
     var isFirstFrame: Bool = false // 是否已显示第一帧加载完成
     var isPlayerError: Bool = false // 是否播放失败
     var loadingTime: TimeInterval = 0 // 加载时长
-
     var playId: String = getUniqueId(desc: "playId") // 播放ID
     /// 进度回调
     public var progressBloc: ((_ loadProgress: Float, _ playProgress: Float, _ duration: Float) -> Void)?
@@ -26,8 +25,11 @@ public class PQSingletoVideoPlayer: NSObject {
     public var playStatusBloc: ((_ playStatus: PQVIDEO_PLAY_STATUS) -> Void)?
     public var playControllerView: UIView?
     public var playVideoData: PQVideoListModel?
+    public var isPlaying: Bool {
+        return player.isPlaying()
+    }
 
-    lazy public var player: TXVodPlayer = {
+    public lazy var player: TXVodPlayer = {
         let player = TXVodPlayer()
         let config = TXVodPlayConfig()
         config.cacheFolderPath = videoCacheDirectory
@@ -69,14 +71,14 @@ 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) {
+        if playControllerView != nil {
             player.removeVideoWidget()
             player.setupVideoWidget(playControllerView, insert: 0)
             if playVideoData!.playProgress >= 0.0 {
@@ -93,10 +95,17 @@ public class PQSingletoVideoPlayer: NSObject {
             }
             playId = getUniqueId(desc: "playId")
             player.startPlay(playVideoData!.videoPath)
-           
         }
     }
 
+    public func pausePlayer() {
+        player.pause()
+    }
+
+    public func resumePlayer() {
+        player.resume()
+    }
+
     public func stopPlayer(isRemove: Bool = true) {
         player.stopPlay()
         if isRemove {