|
@@ -13,7 +13,7 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
public static let shared = PQSingletoVideoPlayer()
|
|
public static let shared = PQSingletoVideoPlayer()
|
|
public var isPlayEnd: Bool = false // 是否已播放完成
|
|
public var isPlayEnd: Bool = false // 是否已播放完成
|
|
public var isRealPlay: Bool = false // 是否已真实播放
|
|
public var isRealPlay: Bool = false // 是否已真实播放
|
|
- public var isSemiRealPlay: Bool = false // 是否已播放到十秒
|
|
|
|
|
|
+ public var isSemiRealPlay: Bool = false // 是否已播放到十秒
|
|
public var isPlayBegin: Bool = false // 是否已缓冲完成开始播放
|
|
public var isPlayBegin: Bool = false // 是否已缓冲完成开始播放
|
|
public var isFirstFrame: Bool = false // 是否已显示第一帧加载完成
|
|
public var isFirstFrame: Bool = false // 是否已显示第一帧加载完成
|
|
public var isPlayerError: Bool = false // 是否播放失败
|
|
public var isPlayerError: Bool = false // 是否播放失败
|
|
@@ -40,6 +40,10 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
return player
|
|
return player
|
|
}()
|
|
}()
|
|
|
|
|
|
|
|
+ /// 配置播放器
|
|
|
|
+ /// - Parameters:
|
|
|
|
+ /// - videoData: <#videoData description#>
|
|
|
|
+ /// - controllerView: <#controllerView description#>
|
|
public func configPlyer(videoData: PQVideoListModel, controllerView: UIView) {
|
|
public func configPlyer(videoData: PQVideoListModel, controllerView: UIView) {
|
|
isPlayEnd = false
|
|
isPlayEnd = false
|
|
isRealPlay = false
|
|
isRealPlay = false
|
|
@@ -48,10 +52,8 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
isFirstFrame = false
|
|
isFirstFrame = false
|
|
isPlayerError = false
|
|
isPlayerError = false
|
|
loadingTime = Date().timeIntervalSince1970 * 1000
|
|
loadingTime = Date().timeIntervalSince1970 * 1000
|
|
-
|
|
|
|
player.stopPlay()
|
|
player.stopPlay()
|
|
player.removeVideoWidget()
|
|
player.removeVideoWidget()
|
|
-
|
|
|
|
player.setupVideoWidget(controllerView, insert: 0)
|
|
player.setupVideoWidget(controllerView, insert: 0)
|
|
player.enableHWAcceleration = true
|
|
player.enableHWAcceleration = true
|
|
playControllerView = controllerView
|
|
playControllerView = controllerView
|
|
@@ -70,13 +72,12 @@ 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)
|
|
|
|
-
|
|
|
|
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()
|
|
@@ -94,18 +95,31 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
player.setStartTime(progress)
|
|
player.setStartTime(progress)
|
|
}
|
|
}
|
|
playId = getUniqueId(desc: "playId")
|
|
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() {
|
|
public func pausePlayer() {
|
|
player.pause()
|
|
player.pause()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// 继续播放
|
|
public func resumePlayer() {
|
|
public func resumePlayer() {
|
|
player.resume()
|
|
player.resume()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// 停止播放
|
|
|
|
+ /// - Parameter isRemove: 是否移除载体视图
|
|
public func stopPlayer(isRemove: Bool = true) {
|
|
public func stopPlayer(isRemove: Bool = true) {
|
|
player.stopPlay()
|
|
player.stopPlay()
|
|
if isRemove {
|
|
if isRemove {
|