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