worked on player
This commit is contained in:
@@ -34,7 +34,6 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
|
||||
// rotateView(to: .pi / 2) // Example: 90 degrees rotation
|
||||
//bring back button to the front
|
||||
self.view.bringSubviewToFront(backButton)
|
||||
|
||||
// NotificationCenter.default.addObserver(self, selector: #selector(appDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
||||
// NotificationCenter.default.addObserver(self, selector: #selector(appWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||
}
|
||||
@@ -68,6 +67,7 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self else{return}
|
||||
appDelegate.deviceOrientation = .landscapeRight
|
||||
@@ -85,9 +85,8 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
player.stop()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@IBAction func backBtnTapped(_ sender: UIButton) {
|
||||
handleBackAction()
|
||||
}
|
||||
@@ -161,11 +160,11 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
|
||||
override func jwplayer(_ player: any JWPlayer, didFinishLoadingWithTime loadTime: TimeInterval) {
|
||||
super.jwplayer(player, didFinishLoadingWithTime: loadTime)
|
||||
print("LoadTime", loadTime)
|
||||
if let videoIndex , contentType == .webSeries, videoIndex != 0{
|
||||
player.nextUpPlaylistIndex = videoIndex
|
||||
player.next()
|
||||
self.videoIndex = nil
|
||||
}
|
||||
// if let videoIndex , contentType == .webSeries, videoIndex != 0{
|
||||
// player.nextUpPlaylistIndex = videoIndex
|
||||
// player.next()
|
||||
// self.videoIndex = nil
|
||||
// }
|
||||
}
|
||||
|
||||
override func jwplayerIsReady(_ player: JWPlayer) {
|
||||
@@ -174,12 +173,17 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
|
||||
case .liveStream:
|
||||
player.play()
|
||||
case .webSeries:
|
||||
if videoIndex == 0{
|
||||
player.seek(to: 0)
|
||||
}else{
|
||||
break
|
||||
// player.loadPlayerItemAt(index: videoIndex ?? 0)
|
||||
// self.player.play(relatedContent: videoIndex ?? 0)
|
||||
// self.player.loadPlayerItemAt(index: videoIndex ?? 0)
|
||||
// player.play()
|
||||
// if videoIndex == 0{
|
||||
// player.seek(to: 0)
|
||||
// }else{
|
||||
// player.nextUpPlaylistIndex = videoIndex ?? 0
|
||||
// player.next()
|
||||
}
|
||||
// }
|
||||
case .trailer,.songs:
|
||||
break
|
||||
case .continueWatching,.audioBooks, .games:
|
||||
@@ -188,7 +192,8 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
|
||||
case nil:
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
|
||||
print("IsReady")
|
||||
}
|
||||
|
||||
|
||||
@@ -400,6 +400,7 @@ class ThemeOneVM{
|
||||
var url = String()
|
||||
var title = String()
|
||||
|
||||
|
||||
if AuthFunc.shareInstance.languageSelected == .english{
|
||||
url = liveStreamData.liveURL?.hdURLEn ?? ""
|
||||
title = liveStreamData.name?.titleEn ?? ""
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import JWPlayerKit
|
||||
|
||||
class WebSeriesSeasonVC: UIViewController {
|
||||
|
||||
@@ -175,6 +176,51 @@ extension WebSeriesSeasonVC : TableViewSRC{
|
||||
|
||||
JWPlayerManager.shared.presentPlayer(from: self, playerItems: playerItems, startIndex: indexPath.row, contentType: .trailer)
|
||||
|
||||
// let builder = JWPlayerConfigurationBuilder()
|
||||
//
|
||||
// do {
|
||||
// let playlist: [JSONObject] = [
|
||||
// [
|
||||
// "file": "https://cdn.jwplayer.com/manifests/gzIo9zlJ.m3u8",
|
||||
// "title": "First Video Title"
|
||||
// ],
|
||||
// [
|
||||
// "file": "https://cdn.jwplayer.com/manifests/pDu0xxUh.m3u8", // replace with the second video URL
|
||||
// "title": "Second Video Title",
|
||||
//
|
||||
// ]
|
||||
// ]
|
||||
//
|
||||
// let json: JSONObject = [
|
||||
// "playlist": playlist,
|
||||
// "playlistIndex": 1,
|
||||
// "videoGravity" : "resize"
|
||||
// ]
|
||||
//
|
||||
// try builder.configuration(json: json).build()
|
||||
//
|
||||
// let config = try builder.configuration(json: json).build()
|
||||
// let sb = UIStoryboard(name: K.StoryBoard.theme, bundle: nil)
|
||||
// let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Theme.playerVC) as! PlayerVC
|
||||
//
|
||||
// vc.config = config
|
||||
// vc.contentType = .liveStream
|
||||
// vc.modalPresentationStyle = .fullScreen
|
||||
// vc.modalTransitionStyle = .crossDissolve
|
||||
//
|
||||
// DispatchQueue.main.async { [weak self] in
|
||||
// guard let self else{return}
|
||||
// // Present the PlayerVC
|
||||
// self.present(vc, animated: false) { [weak self] in
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//// player.configurePlayer(with: config)
|
||||
// } catch {
|
||||
// // Handle build errors
|
||||
// print("Failed to build JWPlayer configuration: \(error.localizedDescription)")
|
||||
// }
|
||||
|
||||
case self.episodeTableView:
|
||||
|
||||
let episodeData = vm.seasonEpisodeData
|
||||
|
||||
@@ -113,7 +113,7 @@ class JWPlayerManager {
|
||||
case .webSeries:
|
||||
finalConfig = try JWPlayerConfigurationBuilder()
|
||||
.playlist(items: items)
|
||||
.autostart(true)
|
||||
.autostart(false)
|
||||
.build()
|
||||
case .trailer:
|
||||
finalConfig = try JWPlayerConfigurationBuilder()
|
||||
@@ -128,15 +128,20 @@ class JWPlayerManager {
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
DispatchQueue.main.async {
|
||||
playerVC.videoIndex = startIndex
|
||||
playerVC.contentType = contentType
|
||||
playerVC.config = finalConfig
|
||||
|
||||
playerVC.modalPresentationStyle = .fullScreen
|
||||
playerVC.modalTransitionStyle = .crossDissolve
|
||||
// Present the PlayerVC
|
||||
Utilities.dismissProgressHUD()
|
||||
viewController.present(playerVC, animated: true) {
|
||||
if contentType == .webSeries{
|
||||
playerVC.player.loadPlayerItemAt(index: startIndex)
|
||||
}
|
||||
completion?()
|
||||
// playerVC.transitionToFullScreen(animated: true) {
|
||||
// print("FullScreen")
|
||||
|
||||
Reference in New Issue
Block a user