|
@@ -7,12 +7,14 @@
|
|
|
// Copyright © 2020 BytesFlow. All rights reserved.
|
|
|
//
|
|
|
|
|
|
-import UIKit
|
|
|
import BFCommonKit
|
|
|
+import UIKit
|
|
|
|
|
|
public class PQSingletoVideoPlayer: NSObject {
|
|
|
public static let shared = PQSingletoVideoPlayer()
|
|
|
public var isPlayEnd: Bool = false // 是否已播放完成
|
|
|
+ public var isHomePageAllList: Bool = false // 首页加入/关注是否是全部列表
|
|
|
+ public var lastPlaybackTime: Float = 0 // 上次上报播放时长
|
|
|
public var isRealPlay: Bool = false // 是否已真实播放
|
|
|
public var isSemiRealPlay: Bool = false // 是否已播放到十秒
|
|
|
public var isPlayBegin: Bool = false // 是否已缓冲完成开始播放
|
|
@@ -29,8 +31,9 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
public var isPlaying: Bool {
|
|
|
return player.isPlaying()
|
|
|
}
|
|
|
- public var autoResumePlayWhenEnterForeground:Bool = true
|
|
|
- var shouldResumePlayWhenEnterForeground:Bool = false
|
|
|
+
|
|
|
+ public var autoResumePlayWhenEnterForeground: Bool = true
|
|
|
+ var shouldResumePlayWhenEnterForeground: Bool = false
|
|
|
|
|
|
public lazy var player: TXVodPlayer = {
|
|
|
let player = TXVodPlayer()
|
|
@@ -47,10 +50,11 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
/// - Parameters:
|
|
|
/// - videoData: <#videoData description#>
|
|
|
/// - controllerView: <#controllerView description#>
|
|
|
- public func configPlyer(videoData: BFVideoItemProtocol, controllerView: UIView, renderMode: TX_Enum_Type_RenderMode = .RENDER_MODE_FILL_SCREEN) {
|
|
|
+ public func configPlyer(videoData: BFVideoItemProtocol, controllerView: UIView, renderMode: TX_Enum_Type_RenderMode = .RENDER_MODE_FILL_SCREEN, isAllList: Bool = false) {
|
|
|
// if playVideoData?.id == videoData.id {
|
|
|
// return
|
|
|
// }
|
|
|
+ isHomePageAllList = isAllList
|
|
|
isPlayEnd = false
|
|
|
isRealPlay = false
|
|
|
isSemiRealPlay = false
|
|
@@ -77,12 +81,13 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
player.setStartTime(progress)
|
|
|
}
|
|
|
playId = getUniqueId(desc: "playId")
|
|
|
+ lastPlaybackTime = 0
|
|
|
BFLog(message: "\(String(describing: videoData.title)) 开始播放 \(videoData.videoPath ?? "")")
|
|
|
if PQSingletoMemoryUtil.shared.playCount < 4 {
|
|
|
PQSingletoMemoryUtil.shared.playCount = PQSingletoMemoryUtil.shared.playCount + 1
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public func reRenderView(newView: UIView) {
|
|
|
player.removeVideoWidget()
|
|
|
player.setupVideoWidget(newView, insert: 0)
|
|
@@ -91,6 +96,20 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
/// 重制播放
|
|
|
public func resetPlayer() {
|
|
|
if playControllerView != nil {
|
|
|
+ let playDuration = player.currentPlaybackTime() - lastPlaybackTime
|
|
|
+ debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
|
|
|
+ if playDuration > 0 {
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
|
|
|
+ } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
|
|
|
+ extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
|
|
|
+ lastPlaybackTime = player.currentPlaybackTime()
|
|
|
+ }
|
|
|
player.removeVideoWidget()
|
|
|
player.setupVideoWidget(playControllerView, insert: 0)
|
|
|
if playVideoData!.playProgress >= 0.0 {
|
|
@@ -122,6 +141,20 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
/// 暂停播放
|
|
|
public func pausePlayer() {
|
|
|
player.pause()
|
|
|
+ let playDuration = player.currentPlaybackTime() - lastPlaybackTime
|
|
|
+ debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
|
|
|
+ if playDuration > 0 {
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
|
|
|
+ } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
|
|
|
+ extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
|
|
|
+ lastPlaybackTime = player.currentPlaybackTime()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// 继续播放
|
|
@@ -130,6 +163,20 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
if renderMode != nil {
|
|
|
player.setRenderMode(renderMode!)
|
|
|
}
|
|
|
+ let playDuration = player.currentPlaybackTime() - lastPlaybackTime
|
|
|
+ debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
|
|
|
+ if playDuration > 0 {
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
|
|
|
+ } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
|
|
|
+ extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
|
|
|
+ lastPlaybackTime = player.currentPlaybackTime()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// 停止播放
|
|
@@ -141,6 +188,20 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
playControllerView = nil
|
|
|
playVideoData = nil
|
|
|
}
|
|
|
+ let playDuration = player.currentPlaybackTime() - lastPlaybackTime
|
|
|
+ debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
|
|
|
+ if playDuration > 0 {
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
|
|
|
+ } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail){
|
|
|
+ extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
|
|
|
+ lastPlaybackTime = player.currentPlaybackTime()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// seek
|
|
@@ -152,23 +213,20 @@ public class PQSingletoVideoPlayer: NSObject {
|
|
|
override private init() {
|
|
|
super.init()
|
|
|
|
|
|
- NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { notice in
|
|
|
+ NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { _ in
|
|
|
if self.isPlaying {
|
|
|
self.pausePlayer()
|
|
|
self.shouldResumePlayWhenEnterForeground = true
|
|
|
}
|
|
|
}
|
|
|
- NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { notice in
|
|
|
-
|
|
|
- if self.autoResumePlayWhenEnterForeground && self.shouldResumePlayWhenEnterForeground {
|
|
|
+ NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { _ in
|
|
|
|
|
|
+ if self.autoResumePlayWhenEnterForeground, self.shouldResumePlayWhenEnterForeground {
|
|
|
self.shouldResumePlayWhenEnterForeground = false
|
|
|
|
|
|
self.resumePlayer()
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
override public func copy() -> Any {
|
|
@@ -203,7 +261,15 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isSemiRealPlay, playVideoData != nil {
|
|
|
isSemiRealPlay = true
|
|
|
// 播放上报
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoSemiRealPlay, objectType: nil, extParams: nil, shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": "all"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": "all"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoSemiRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
}
|
|
|
}
|
|
|
if player.currentPlaybackTime() >= 20.0 || ((playProgress / duration) >= 0.3) {
|
|
@@ -211,7 +277,15 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isRealPlay, playVideoData != nil {
|
|
|
isRealPlay = true
|
|
|
// 播放上报
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_realPlay, videoData: playVideoData, pageSource: nil, businessType: .bt_videoRealPlay, objectType: nil, extParams: nil, shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": "all"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": "all"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_realPlay, videoData: playVideoData, pageSource: nil, businessType: .bt_videoRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
}
|
|
|
}
|
|
|
playVideoData?.playProgress = Float64(playProgress)
|
|
@@ -223,7 +297,15 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isPlayBegin, playVideoData != nil {
|
|
|
isPlayBegin = true
|
|
|
// 播放上报
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccess, objectType: nil, extParams: nil, shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": "all"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": "all"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccess, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
}
|
|
|
|
|
|
case PLAY_EVT_PLAY_LOADING.rawValue: // 视频播放loading
|
|
@@ -238,11 +320,25 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isFirstFrame, playVideoData != nil {
|
|
|
isFirstFrame = true
|
|
|
// 播放上报
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_play, videoData: playVideoData, pageSource: nil, businessType: nil, objectType: nil, extParams: nil, shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": "all"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": "all"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_play, videoData: playVideoData, pageSource: nil, businessType: nil, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
let duration = Int((Date().timeIntervalSince1970 * 1000) - loadingTime)
|
|
|
BFLog(message: "加载时长:\(duration)")
|
|
|
// 加载时间上报
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccessTime, objectType: nil, extParams: ["duration": duration, "proxyEnable": "0", "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0"], shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var timeExtParams: [String: Any] = ["duration": duration, "proxyEnable": "0", "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0"]
|
|
|
+ if extParams != nil {
|
|
|
+ timeExtParams.merge(extParams!) { keyValue, _ in
|
|
|
+ keyValue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccessTime, objectType: nil, extParams: timeExtParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
}
|
|
|
BFLog(message: "首帧加载完成")
|
|
|
case PLAY_EVT_PLAY_END.rawValue: // 播放结束
|
|
@@ -254,7 +350,29 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isPlayEnd, playVideoData != nil {
|
|
|
isPlayEnd = true
|
|
|
// 播放结束上报
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayEnd, objectType: nil, extParams: nil, shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": "all"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": "all"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayEnd, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ }
|
|
|
+ let playDuration = player.currentPlaybackTime() - lastPlaybackTime
|
|
|
+ debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
|
|
|
+ if playDuration > 0 {
|
|
|
+ var extParams: [String: Any]?
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
|
|
|
+ } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
|
|
|
+ extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
|
|
|
+ lastPlaybackTime = player.currentPlaybackTime()
|
|
|
}
|
|
|
case PLAY_ERR_NET_DISCONNECT.rawValue, -2301: // 重连失败
|
|
|
if playStatusBloc != nil {
|
|
@@ -263,7 +381,15 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isPlayerError, playVideoData != nil {
|
|
|
isPlayerError = true
|
|
|
// 播放失败
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event], shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams["topicId"] = "all"
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams["followedUid"] = "all"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
}
|
|
|
case PLAY_ERR_FILE_NOT_FOUND.rawValue: // 播放文件不存在
|
|
|
if playStatusBloc != nil {
|
|
@@ -272,7 +398,15 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isPlayerError, playVideoData != nil {
|
|
|
isPlayerError = true
|
|
|
// 播放失败
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event], shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams["topicId"] = "all"
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams["followedUid"] = "all"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
}
|
|
|
case PLAY_ERR_HEVC_DECODE_FAIL.rawValue, PLAY_ERR_HLS_KEY.rawValue, PLAY_ERR_GET_PLAYINFO_FAIL.rawValue, PLAY_WARNING_VIDEO_DECODE_FAIL.rawValue, PLAY_WARNING_AUDIO_DECODE_FAIL.rawValue: // H265解码失败,HLS解码key获取失败,获取点播文件信息失败,当前视频解码失败,当前音频解码失败
|
|
|
if playStatusBloc != nil {
|
|
@@ -281,17 +415,44 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
|
|
|
if !isPlayerError, playVideoData != nil {
|
|
|
isPlayerError = true
|
|
|
// 播放失败
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event], shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams["topicId"] = "all"
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams["followedUid"] = "all"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
}
|
|
|
case PLAY_WARNING_RECONNECT.rawValue: // 断线重连已启动重新连接
|
|
|
if playStatusBloc != nil {
|
|
|
playStatusBloc!(.PQVIDEO_PLAY_STATUS_RECONNECT)
|
|
|
}
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event], shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams["topicId"] = "all"
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams["followedUid"] = "all"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
|
|
|
case PLAY_WARNING_RECV_DATA_LAG.rawValue, PLAY_WARNING_VIDEO_PLAY_LAG.rawValue: // 网络来包不稳:可能是下行带宽不足 | 当前视频播放出现卡顿(用户直观感受)
|
|
|
// 播放失败
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySlow, objectType: nil, extParams: ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event, "position": player.currentPlaybackTime()], shareId: nil, videoIds: nil, playId: playId)
|
|
|
- PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event], shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ var extParams1: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event, "position": player.currentPlaybackTime()]
|
|
|
+ var extParams2: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
|
|
|
+ if isHomePageAllList {
|
|
|
+ if playVideoData?.pageSource == .sp_cmunit_joinTopic {
|
|
|
+ extParams1["topicId"] = "all"
|
|
|
+ extParams2["topicId"] = "all"
|
|
|
+ } else if playVideoData?.pageSource == .sp_cmunit_follow {
|
|
|
+ extParams1["followedUid"] = "all"
|
|
|
+ extParams2["topicId"] = "all"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySlow, objectType: nil, extParams: extParams1, shareId: nil, videoIds: nil, playId: playId)
|
|
|
+ PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: extParams2, shareId: nil, videoIds: nil, playId: playId)
|
|
|
default:
|
|
|
break
|
|
|
}
|