修复bug
This commit is contained in:
parent
8759b6f80c
commit
7e37c16187
@ -218,7 +218,7 @@ extension VPVipAlertView {
|
|||||||
bgView.snp.makeConstraints { make in
|
bgView.snp.makeConstraints { make in
|
||||||
make.top.left.right.equalToSuperview()
|
make.top.left.right.equalToSuperview()
|
||||||
make.width.equalTo(274)
|
make.width.equalTo(274)
|
||||||
make.height.equalTo(330)
|
// make.height.equalTo(330)
|
||||||
}
|
}
|
||||||
|
|
||||||
bgIconImageView.snp.makeConstraints { make in
|
bgIconImageView.snp.makeConstraints { make in
|
||||||
@ -249,6 +249,7 @@ extension VPVipAlertView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vipBgView.snp.makeConstraints { make in
|
vipBgView.snp.makeConstraints { make in
|
||||||
|
make.top.equalTo(textLabel.snp.bottom).offset(15)
|
||||||
make.centerX.equalToSuperview()
|
make.centerX.equalToSuperview()
|
||||||
make.bottom.equalToSuperview().offset(-22)
|
make.bottom.equalToSuperview().offset(-22)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,6 @@ class VPDetailPlayerViewController: VPVideoPlayerViewController {
|
|||||||
|
|
||||||
//播放完成上报进度为0
|
//播放完成上报进度为0
|
||||||
VPVideoAPI.requestUploadPlayProgress(shortPlayId: shortPlayId, videoId: videoId, seconds: 0)
|
VPVideoAPI.requestUploadPlayProgress(shortPlayId: shortPlayId, videoId: videoId, seconds: 0)
|
||||||
self.viewModel.currentPlayer?.videoInfo?.play_seconds = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.currentPlayFinish()
|
super.currentPlayFinish()
|
||||||
@ -253,7 +252,7 @@ extension VPDetailPlayerViewController {
|
|||||||
if currentTime >= duration {
|
if currentTime >= duration {
|
||||||
time = 0
|
time = 0
|
||||||
}
|
}
|
||||||
self.viewModel.currentPlayer?.videoInfo?.play_seconds = time * 1000
|
// self.viewModel.currentPlayer?.videoInfo?.play_seconds = time * 1000
|
||||||
|
|
||||||
guard let shortPlayId = videoInfo?.short_play_id, let videoId = videoInfo?.short_play_video_id else { return }
|
guard let shortPlayId = videoInfo?.short_play_id, let videoId = videoInfo?.short_play_video_id else { return }
|
||||||
//上报播放时长
|
//上报播放时长
|
||||||
|
@ -205,6 +205,8 @@ class VPVideoPlayerViewController: VPViewController {
|
|||||||
|
|
||||||
///当前播放完成 子类可重写
|
///当前播放完成 子类可重写
|
||||||
func currentPlayFinish() {
|
func currentPlayFinish() {
|
||||||
|
self.viewModel.currentPlayer?.videoInfo?.play_seconds = 0
|
||||||
|
|
||||||
if self.autoNextEpisode {
|
if self.autoNextEpisode {
|
||||||
scrollToNextEpisode()
|
scrollToNextEpisode()
|
||||||
}
|
}
|
||||||
@ -212,6 +214,16 @@ class VPVideoPlayerViewController: VPViewController {
|
|||||||
|
|
||||||
///当前播放进度变更 子类可重写
|
///当前播放进度变更 子类可重写
|
||||||
func currentPlayTimeDidChange(time: Int) {
|
func currentPlayTimeDidChange(time: Int) {
|
||||||
|
guard time > 1 else { return }
|
||||||
|
|
||||||
|
let currentTime = self.viewModel.currentPlayer?.currentPosition ?? 0
|
||||||
|
let duration = self.viewModel.currentPlayer?.duration ?? 0
|
||||||
|
|
||||||
|
var time = currentTime
|
||||||
|
if currentTime >= duration {
|
||||||
|
time = 0
|
||||||
|
}
|
||||||
|
self.viewModel.currentPlayer?.videoInfo?.play_seconds = time * 1000
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,6 +390,7 @@ extension VPVideoPlayerViewController {
|
|||||||
|
|
||||||
@objc func didBecomeActiveNotification() {
|
@objc func didBecomeActiveNotification() {
|
||||||
if getDataCount() > 0 && self.viewModel.isPlaying && isDidAppear {
|
if getDataCount() > 0 && self.viewModel.isPlaying && isDidAppear {
|
||||||
|
self.viewModel.currentPlayer?.prepare()//进入后台回来后会出现播放器无法正常播放的情况,需要重置播放器
|
||||||
self.viewModel.currentPlayer?.start()
|
self.viewModel.currentPlayer?.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,9 @@ class VPVideoPlayerCell: VPCollectionViewCell, VPPlayerProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func prepare() {
|
func prepare() {
|
||||||
|
player.setPlayUrl(url: videoInfo?.video_url ?? "")
|
||||||
|
// self.player.stop()
|
||||||
|
// self.player.prepare()
|
||||||
}
|
}
|
||||||
|
|
||||||
func start() {
|
func start() {
|
||||||
|
@ -148,9 +148,9 @@ class VPPlayer: NSObject {
|
|||||||
|
|
||||||
func setPlayUrl(url: String) {
|
func setPlayUrl(url: String) {
|
||||||
let proxyURL = KTVHTTPCache.proxyURL(withOriginalURL: URL(string: url))
|
let proxyURL = KTVHTTPCache.proxyURL(withOriginalURL: URL(string: url))
|
||||||
if proxyURL != self.player.assetURL {
|
// if proxyURL != self.player.assetURL {
|
||||||
self.player.assetURL = proxyURL
|
// }
|
||||||
}
|
self.player.assetURL = proxyURL
|
||||||
// self.prepare()
|
// self.prepare()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,26 +224,30 @@ extension VPPlayer {
|
|||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
if playState == .playStatePlaying && !isPlaying {
|
if playState == .playStatePlaying && !isPlaying {
|
||||||
self.pause()
|
self.pause()
|
||||||
} else if playState == .playStatePaused, isPlaying, self.interruptionType != .began {
|
} else if playState == .playStatePaused, isPlaying {
|
||||||
self.start()
|
self.start()
|
||||||
}
|
}
|
||||||
switch playState {
|
switch playState {
|
||||||
case .playStateUnknown:
|
case .playStateUnknown:
|
||||||
|
vpLog(message: "播放状态====playStateUnknown")
|
||||||
self.playState = .unknown
|
self.playState = .unknown
|
||||||
case .playStatePlaying:
|
case .playStatePlaying:
|
||||||
|
vpLog(message: "播放状态====playStatePlaying")
|
||||||
self.playState = .playing
|
self.playState = .playing
|
||||||
case .playStatePaused:
|
case .playStatePaused:
|
||||||
|
vpLog(message: "播放状态====playStatePaused")
|
||||||
self.playState = .paused
|
self.playState = .paused
|
||||||
case .playStatePlayStopped:
|
case .playStatePlayStopped:
|
||||||
|
vpLog(message: "播放状态====playStatePlayStopped")
|
||||||
self.playState = .stopped
|
self.playState = .stopped
|
||||||
case .playStatePlayFailed:
|
case .playStatePlayFailed:
|
||||||
|
vpLog(message: "播放状态====playStatePlayFailed")
|
||||||
self.playState = .failed
|
self.playState = .failed
|
||||||
|
|
||||||
default:
|
default:
|
||||||
self.playState = .unknown
|
self.playState = .unknown
|
||||||
}
|
}
|
||||||
self.delegate?.vp_player?(self, playStateDidChanged: self.playState)
|
self.delegate?.vp_player?(self, playStateDidChanged: self.playState)
|
||||||
vpLog(message: "播放状态====\(playState)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//加载状态
|
//加载状态
|
||||||
@ -251,22 +255,27 @@ extension VPPlayer {
|
|||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
if loadState == .playable && !isPlaying {
|
if loadState == .playable && !isPlaying {
|
||||||
self.pause()
|
self.pause()
|
||||||
} else if loadState == .playable, isPlaying, self.player.playState != .playStatePlaying, self.interruptionType != .began {
|
} else if loadState == .playable, isPlaying, self.player.playState != .playStatePlaying {
|
||||||
self.start()
|
self.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
switch loadState {
|
switch loadState {
|
||||||
case .prepare:
|
case .prepare:
|
||||||
self.loadState = .prepare
|
vpLog(message: "加载状态====prepare\(loadState)")
|
||||||
case .playable:
|
self.loadState = .prepare
|
||||||
self.loadState = .playable
|
case .playable:
|
||||||
case .playthroughOK:
|
vpLog(message: "加载状态====playable\(loadState)")
|
||||||
self.loadState = .playthroughOK
|
self.loadState = .playable
|
||||||
case .stalled:
|
case .playthroughOK:
|
||||||
self.loadState = .stalled
|
vpLog(message: "加载状态====playthroughOK\(loadState)")
|
||||||
default:
|
self.loadState = .playthroughOK
|
||||||
self.loadState = .unknown
|
case .stalled:
|
||||||
break
|
vpLog(message: "加载状态====stalled\(loadState)")
|
||||||
|
self.loadState = .stalled
|
||||||
|
default:
|
||||||
|
vpLog(message: "加载状态====unknown\(loadState)")
|
||||||
|
self.loadState = .unknown
|
||||||
|
break
|
||||||
}
|
}
|
||||||
self.delegate?.vp_player?(self, loadStateDidChange: self.loadState)
|
self.delegate?.vp_player?(self, loadStateDidChange: self.loadState)
|
||||||
}
|
}
|
||||||
@ -317,7 +326,7 @@ extension VPPlayer {
|
|||||||
self.player.play()
|
self.player.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// vpLog(message: "======音频发生变化\(interruptionType)")
|
vpLog(message: "======音频发生变化\(interruptionType)")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user