Compare commits
3 Commits
fbc2d11d48
...
4f402efabf
Author | SHA1 | Date | |
---|---|---|---|
|
4f402efabf | ||
|
6e970b4a73 | ||
|
8ebd677a1e |
@ -25,6 +25,7 @@ class SPVideoAPI: NSObject {
|
|||||||
var param = SPNetworkParameters(path: "/getVideoDetails")
|
var param = SPNetworkParameters(path: "/getVideoDetails")
|
||||||
param.method = .get
|
param.method = .get
|
||||||
param.parameters = parameters
|
param.parameters = parameters
|
||||||
|
param.isLoding = true
|
||||||
|
|
||||||
SPNetwork.request(parameters: param) { (response: SPNetworkResponse<SPVideoDetailModel>) in
|
SPNetwork.request(parameters: param) { (response: SPNetworkResponse<SPVideoDetailModel>) in
|
||||||
completer?(response.data)
|
completer?(response.data)
|
||||||
|
@ -127,7 +127,7 @@ class SPPlayerDetailViewController: SPPlayerListViewController {
|
|||||||
|
|
||||||
//播放完成上报进度为0
|
//播放完成上报进度为0
|
||||||
SPVideoAPI.requestUploadPlayTime(shortPlayId: shortPlayId, videoId: videoId, seconds: 0)
|
SPVideoAPI.requestUploadPlayTime(shortPlayId: shortPlayId, videoId: videoId, seconds: 0)
|
||||||
self.viewModel.currentPlayer?.videoInfo?.play_seconds = 0
|
// self.viewModel.currentPlayer?.videoInfo?.play_seconds = 0
|
||||||
}
|
}
|
||||||
super.currentPlayFinish()
|
super.currentPlayFinish()
|
||||||
}
|
}
|
||||||
@ -235,6 +235,10 @@ extension SPPlayerDetailViewController {
|
|||||||
let view = SPPlayBuyView()
|
let view = SPPlayBuyView()
|
||||||
view.shortPlayId = videoInfo.short_play_id
|
view.shortPlayId = videoInfo.short_play_id
|
||||||
view.videoId = videoInfo.short_play_video_id
|
view.videoId = videoInfo.short_play_video_id
|
||||||
|
view.buyFinishBlock = { [weak self] in
|
||||||
|
guard let self = self else { return }
|
||||||
|
self.requestDetailData(indexPath: self.currentIndexPath)
|
||||||
|
}
|
||||||
view.present(in: nil)
|
view.present(in: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +290,7 @@ extension SPPlayerDetailViewController {
|
|||||||
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 }
|
||||||
//上报播放时长
|
//上报播放时长
|
||||||
@ -295,15 +299,15 @@ extension SPPlayerDetailViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func buyVipFinishNotification() {
|
@objc private func buyVipFinishNotification() {
|
||||||
guard SPLoginManager.manager.userInfo?.is_vip == true else { return }
|
// guard SPLoginManager.manager.userInfo?.is_vip == true else { return }
|
||||||
|
//
|
||||||
self.detailModel?.episodeList?.forEach({
|
// self.detailModel?.episodeList?.forEach({
|
||||||
$0.is_lock = false
|
// $0.is_lock = false
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
self.reloadData { [weak self] in
|
// self.reloadData { [weak self] in
|
||||||
self?.play()
|
// self?.play()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
///网络切换通知
|
///网络切换通知
|
||||||
@objc private func reachabilityDidChangeNotification() {
|
@objc private func reachabilityDidChangeNotification() {
|
||||||
@ -368,7 +372,7 @@ extension SPPlayerDetailViewController {
|
|||||||
|
|
||||||
extension SPPlayerDetailViewController {
|
extension SPPlayerDetailViewController {
|
||||||
|
|
||||||
private func requestDetailData() {
|
private func requestDetailData(indexPath: IndexPath? = nil) {
|
||||||
guard let shortPlayId = self.shortPlayId else { return }
|
guard let shortPlayId = self.shortPlayId else { return }
|
||||||
isShowRecommand = false
|
isShowRecommand = false
|
||||||
recommandTimer?.invalidate()
|
recommandTimer?.invalidate()
|
||||||
@ -382,7 +386,10 @@ extension SPPlayerDetailViewController {
|
|||||||
self.reloadData { [weak self] in
|
self.reloadData { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
if let videoInfo = self.detailModel?.video_info {
|
if let indexPath = indexPath, indexPath.row < (model.episodeList?.count ?? 0) {
|
||||||
|
self.scrollToItem(indexPath: indexPath, animated: false)
|
||||||
|
|
||||||
|
} else if let videoInfo = self.detailModel?.video_info {
|
||||||
var row: Int?
|
var row: Int?
|
||||||
self.detailModel?.episodeList?.enumerated().forEach({
|
self.detailModel?.episodeList?.enumerated().forEach({
|
||||||
if $1.id == videoInfo.id {
|
if $1.id == videoInfo.id {
|
||||||
@ -390,11 +397,7 @@ extension SPPlayerDetailViewController {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
if let row = row {
|
if let row = row {
|
||||||
self.scrollToItem(indexPath: IndexPath(row: row, section: 0), animated: false) { [weak self] in
|
self.scrollToItem(indexPath: .init(row: row, section: 0), animated: false)
|
||||||
guard let self = self else { return }
|
|
||||||
//跳转到指定进度
|
|
||||||
// self.viewModel.currentPlayer?.seekToTime(toTime: (videoInfo.play_seconds ?? 0) / 1000)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.scrollToItem(indexPath: .init(row: 0, section: 0), animated: false)
|
self.scrollToItem(indexPath: .init(row: 0, section: 0), animated: false)
|
||||||
}
|
}
|
||||||
|
@ -231,11 +231,21 @@ class SPPlayerListViewController: SPViewController {
|
|||||||
if self.autoNextEpisode {
|
if self.autoNextEpisode {
|
||||||
scrollToNextEpisode()
|
scrollToNextEpisode()
|
||||||
}
|
}
|
||||||
|
self.viewModel.currentPlayer?.videoInfo?.play_seconds = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
///当前播放进度变更 子类可重写
|
///当前播放进度变更 子类可重写
|
||||||
func currentPlayTimeDidChange(time: Int) {
|
func currentPlayTimeDidChange(time: Int) {
|
||||||
|
let currentTime = self.viewModel.currentPlayer?.currentPosition ?? 0
|
||||||
|
// let duration = self.viewModel.currentPlayer?.duration ?? 0
|
||||||
|
//
|
||||||
|
// var time = currentTime
|
||||||
|
// if currentTime >= duration {
|
||||||
|
// time = 0
|
||||||
|
// }
|
||||||
|
if time > 1 {
|
||||||
|
self.viewModel.currentPlayer?.videoInfo?.play_seconds = time * 1000
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,6 +397,7 @@ extension SPPlayerListViewController {
|
|||||||
|
|
||||||
@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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import UIKit
|
|||||||
|
|
||||||
class SPPlayBuyView: HWPanModalContentView {
|
class SPPlayBuyView: HWPanModalContentView {
|
||||||
|
|
||||||
|
var buyFinishBlock: (() -> Void)?
|
||||||
|
|
||||||
var shortPlayId: String? {
|
var shortPlayId: String? {
|
||||||
didSet {
|
didSet {
|
||||||
rechargeView.shortPlayId = shortPlayId
|
rechargeView.shortPlayId = shortPlayId
|
||||||
@ -122,6 +124,7 @@ extension SPPlayBuyView {
|
|||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.rechargeView.userInfo = SPLoginManager.manager.userInfo
|
self.rechargeView.userInfo = SPLoginManager.manager.userInfo
|
||||||
}
|
}
|
||||||
|
self.buyFinishBlock?()
|
||||||
|
|
||||||
self.dismiss(animated: true) {
|
self.dismiss(animated: true) {
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class SPPlayerListCell: SPCollectionViewCell, SPPlayerProtocol {
|
|||||||
var playerFinishHadle: (() -> Void)?
|
var playerFinishHadle: (() -> Void)?
|
||||||
|
|
||||||
func prepare() {
|
func prepare() {
|
||||||
// player.prepare()
|
player.setPlayUrl(url: videoInfo?.video_url ?? "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func start() {
|
func start() {
|
||||||
|
@ -148,9 +148,9 @@ class SPPlayer: 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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user