- Fixed player issue
This commit is contained in:
@@ -249,7 +249,6 @@
|
|||||||
52DAC6482C21762900E2F85B /* WebSeries.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52DAC6472C21762900E2F85B /* WebSeries.storyboard */; };
|
52DAC6482C21762900E2F85B /* WebSeries.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52DAC6472C21762900E2F85B /* WebSeries.storyboard */; };
|
||||||
52DAC64E2C21775300E2F85B /* WebSeriesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52DAC64D2C21775300E2F85B /* WebSeriesVC.swift */; };
|
52DAC64E2C21775300E2F85B /* WebSeriesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52DAC64D2C21775300E2F85B /* WebSeriesVC.swift */; };
|
||||||
52E214C72C2AD47F00BC2D29 /* EpisodeDetailsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52E214C62C2AD47F00BC2D29 /* EpisodeDetailsVC.swift */; };
|
52E214C72C2AD47F00BC2D29 /* EpisodeDetailsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52E214C62C2AD47F00BC2D29 /* EpisodeDetailsVC.swift */; };
|
||||||
52F37C342C7C56110001C176 /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 52F37C322C7C56100001C176 /* WOKA.xcdatamodeld */; };
|
|
||||||
52F4E8662C3D123B00778FBC /* JWKaraokePlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52F4E8652C3D123B00778FBC /* JWKaraokePlayerVC.swift */; };
|
52F4E8662C3D123B00778FBC /* JWKaraokePlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52F4E8652C3D123B00778FBC /* JWKaraokePlayerVC.swift */; };
|
||||||
52FB2D8F2BDF898F0009B0C7 /* TextFieldPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FB2D8E2BDF898F0009B0C7 /* TextFieldPadding.swift */; };
|
52FB2D8F2BDF898F0009B0C7 /* TextFieldPadding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FB2D8E2BDF898F0009B0C7 /* TextFieldPadding.swift */; };
|
||||||
52FDBA782BFF23F4009D7AC7 /* TimePeriod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FDBA772BFF23F4009D7AC7 /* TimePeriod.swift */; };
|
52FDBA782BFF23F4009D7AC7 /* TimePeriod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FDBA772BFF23F4009D7AC7 /* TimePeriod.swift */; };
|
||||||
@@ -357,6 +356,7 @@
|
|||||||
9CDAEB142C54132E00890C47 /* CheckEddDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CDAEB132C54132E00890C47 /* CheckEddDM.swift */; };
|
9CDAEB142C54132E00890C47 /* CheckEddDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CDAEB132C54132E00890C47 /* CheckEddDM.swift */; };
|
||||||
9CDC343C2BDBBC6B00093089 /* SelectAgeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CDC343B2BDBBC6B00093089 /* SelectAgeVC.swift */; };
|
9CDC343C2BDBBC6B00093089 /* SelectAgeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CDC343B2BDBBC6B00093089 /* SelectAgeVC.swift */; };
|
||||||
9CDCE1452BDB9B9A003FEF11 /* OnBoardMainSound.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 9CDCE1442BDB9B9A003FEF11 /* OnBoardMainSound.m4a */; };
|
9CDCE1452BDB9B9A003FEF11 /* OnBoardMainSound.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 9CDCE1442BDB9B9A003FEF11 /* OnBoardMainSound.m4a */; };
|
||||||
|
9CF8994C2C8191F70038790E /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 9CF8994A2C8191F70038790E /* WOKA.xcdatamodeld */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@@ -650,7 +650,6 @@
|
|||||||
52E214C62C2AD47F00BC2D29 /* EpisodeDetailsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EpisodeDetailsVC.swift; sourceTree = "<group>"; };
|
52E214C62C2AD47F00BC2D29 /* EpisodeDetailsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EpisodeDetailsVC.swift; sourceTree = "<group>"; };
|
||||||
52E7E0F62BDF7DD500C86E10 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/AuthenticationSB.strings; sourceTree = "<group>"; };
|
52E7E0F62BDF7DD500C86E10 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/AuthenticationSB.strings; sourceTree = "<group>"; };
|
||||||
52E7E0F82BDF7DD900C86E10 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/AuthenticationSB.strings; sourceTree = "<group>"; };
|
52E7E0F82BDF7DD900C86E10 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/AuthenticationSB.strings; sourceTree = "<group>"; };
|
||||||
52F37C332C7C56100001C176 /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
|
|
||||||
52F477A42C492ED900F79200 /* JWPlayerKit.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = JWPlayerKit.xcframework; path = Pods/JWPlayerKit/JWPlayerKit.xcframework; sourceTree = "<group>"; };
|
52F477A42C492ED900F79200 /* JWPlayerKit.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = JWPlayerKit.xcframework; path = Pods/JWPlayerKit/JWPlayerKit.xcframework; sourceTree = "<group>"; };
|
||||||
52F4E8652C3D123B00778FBC /* JWKaraokePlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKaraokePlayerVC.swift; sourceTree = "<group>"; };
|
52F4E8652C3D123B00778FBC /* JWKaraokePlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKaraokePlayerVC.swift; sourceTree = "<group>"; };
|
||||||
52FB2D8E2BDF898F0009B0C7 /* TextFieldPadding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldPadding.swift; sourceTree = "<group>"; };
|
52FB2D8E2BDF898F0009B0C7 /* TextFieldPadding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldPadding.swift; sourceTree = "<group>"; };
|
||||||
@@ -748,6 +747,7 @@
|
|||||||
9CDCE1412BDB94BA003FEF11 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Main.strings; sourceTree = "<group>"; };
|
9CDCE1412BDB94BA003FEF11 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Main.strings; sourceTree = "<group>"; };
|
||||||
9CDCE1422BDB94BD003FEF11 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
|
9CDCE1422BDB94BD003FEF11 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
|
||||||
9CDCE1442BDB9B9A003FEF11 /* OnBoardMainSound.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = OnBoardMainSound.m4a; sourceTree = "<group>"; };
|
9CDCE1442BDB9B9A003FEF11 /* OnBoardMainSound.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = OnBoardMainSound.m4a; sourceTree = "<group>"; };
|
||||||
|
9CF8994B2C8191F70038790E /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
|
||||||
C83A2BA3B8F575DC890CC5DD /* Pods-WOKA.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WOKA.debug.xcconfig"; path = "Target Support Files/Pods-WOKA/Pods-WOKA.debug.xcconfig"; sourceTree = "<group>"; };
|
C83A2BA3B8F575DC890CC5DD /* Pods-WOKA.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WOKA.debug.xcconfig"; path = "Target Support Files/Pods-WOKA/Pods-WOKA.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@@ -954,7 +954,7 @@
|
|||||||
9C535DC82C00C34000DA6DCD /* Theme */,
|
9C535DC82C00C34000DA6DCD /* Theme */,
|
||||||
52DAC6462C21761700E2F85B /* WebSeries */,
|
52DAC6462C21761700E2F85B /* WebSeries */,
|
||||||
9C834ED92C1C20EC00B29A9C /* WOKA.entitlements */,
|
9C834ED92C1C20EC00B29A9C /* WOKA.entitlements */,
|
||||||
52F37C322C7C56100001C176 /* WOKA.xcdatamodeld */,
|
9CF8994A2C8191F70038790E /* WOKA.xcdatamodeld */,
|
||||||
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
|
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
|
||||||
);
|
);
|
||||||
path = WOKA;
|
path = WOKA;
|
||||||
@@ -2448,6 +2448,7 @@
|
|||||||
9CBE1B432C0F37B300CA6E61 /* DropDown.swift in Sources */,
|
9CBE1B432C0F37B300CA6E61 /* DropDown.swift in Sources */,
|
||||||
52A6DC9C2C4E38E000F63C51 /* ShopListingVC.swift in Sources */,
|
52A6DC9C2C4E38E000F63C51 /* ShopListingVC.swift in Sources */,
|
||||||
52C8B0742BDA7626003B51D0 /* OnBoardVC.swift in Sources */,
|
52C8B0742BDA7626003B51D0 /* OnBoardVC.swift in Sources */,
|
||||||
|
9CF8994C2C8191F70038790E /* WOKA.xcdatamodeld in Sources */,
|
||||||
5219C2C22C086D9C00A1DF4D /* DataTypeConversion.swift in Sources */,
|
5219C2C22C086D9C00A1DF4D /* DataTypeConversion.swift in Sources */,
|
||||||
525953CF2BE8B28F00191286 /* Utilities.swift in Sources */,
|
525953CF2BE8B28F00191286 /* Utilities.swift in Sources */,
|
||||||
52BFB5332C33DAD700BAAE15 /* AudioBookHomeVC.swift in Sources */,
|
52BFB5332C33DAD700BAAE15 /* AudioBookHomeVC.swift in Sources */,
|
||||||
@@ -2471,7 +2472,6 @@
|
|||||||
52ACC1262C610CBC00791528 /* UserClicks+CoreDataProperties.swift in Sources */,
|
52ACC1262C610CBC00791528 /* UserClicks+CoreDataProperties.swift in Sources */,
|
||||||
9CBCB29D2BE4D6BB007D7934 /* LoginVM.swift in Sources */,
|
9CBCB29D2BE4D6BB007D7934 /* LoginVM.swift in Sources */,
|
||||||
52BBFCB42C5275E100F7D0D1 /* AddressListVM.swift in Sources */,
|
52BBFCB42C5275E100F7D0D1 /* AddressListVM.swift in Sources */,
|
||||||
52F37C342C7C56110001C176 /* WOKA.xcdatamodeld in Sources */,
|
|
||||||
524C42312C0499560016A11C /* NotificationCenterReloads.swift in Sources */,
|
524C42312C0499560016A11C /* NotificationCenterReloads.swift in Sources */,
|
||||||
9C8C4FAE2C1315410017DD3B /* WebViewVC.swift in Sources */,
|
9C8C4FAE2C1315410017DD3B /* WebViewVC.swift in Sources */,
|
||||||
52BBFCB62C52764B00F7D0D1 /* AddressListDM.swift in Sources */,
|
52BBFCB62C52764B00F7D0D1 /* AddressListDM.swift in Sources */,
|
||||||
@@ -3110,14 +3110,14 @@
|
|||||||
/* End XCSwiftPackageProductDependency section */
|
/* End XCSwiftPackageProductDependency section */
|
||||||
|
|
||||||
/* Begin XCVersionGroup section */
|
/* Begin XCVersionGroup section */
|
||||||
52F37C322C7C56100001C176 /* WOKA.xcdatamodeld */ = {
|
9CF8994A2C8191F70038790E /* WOKA.xcdatamodeld */ = {
|
||||||
isa = XCVersionGroup;
|
isa = XCVersionGroup;
|
||||||
children = (
|
children = (
|
||||||
52F37C332C7C56100001C176 /* WOKA.xcdatamodel */,
|
9CF8994B2C8191F70038790E /* WOKA.xcdatamodel */,
|
||||||
);
|
);
|
||||||
currentVersion = 52F37C332C7C56100001C176 /* WOKA.xcdatamodel */;
|
currentVersion = 9CF8994B2C8191F70038790E /* WOKA.xcdatamodel */;
|
||||||
name = WOKA.xcdatamodeld;
|
name = WOKA.xcdatamodeld;
|
||||||
path = /Users/macbookpro/Desktop/WOKA/WOKA/WOKA.xcdatamodeld;
|
path = /Users/bilal/Desktop/woka_native_ios_swift/WOKA/WOKA.xcdatamodeld;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
versionGroupType = wrapper.xcdatamodel;
|
versionGroupType = wrapper.xcdatamodel;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ class NetworkReachibility{
|
|||||||
var isMonitoring = false
|
var isMonitoring = false
|
||||||
fileprivate var isInternetReachable = false
|
fileprivate var isInternetReachable = false
|
||||||
|
|
||||||
func startMonitoring(onCompletion : @escaping (Bool) -> Void) {
|
func startMonitoring(queue : DispatchQueue? = .main,onCompletion : @escaping (Bool) -> Void) {
|
||||||
manager?.startListening(onQueue: DispatchQueue.main, onUpdatePerforming: { (status) in
|
manager?.startListening(onQueue: queue!, onUpdatePerforming: { (status) in
|
||||||
self.isMonitoring = true
|
self.isMonitoring = true
|
||||||
switch status {
|
switch status {
|
||||||
case .notReachable:
|
case .notReachable:
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ class ThemeOneVC: UIViewController {
|
|||||||
NotificationCenter.default.removeObserver(self, name: UIApplication.willEnterForegroundNotification, object: nil)
|
NotificationCenter.default.removeObserver(self, name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||||
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
|
||||||
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.themeOnePush), object: nil)
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.themeOnePush), object: nil)
|
||||||
NetworkMonitor.shared.stopMonitoring()
|
// NotificationCenter.default.removeObserver(self, name: NSNotification.Name.connectivityStatus, object: nil)
|
||||||
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.connectivityStatus, object: nil)
|
|
||||||
if let playerItem = vm.playerItem{
|
if let playerItem = vm.playerItem{
|
||||||
playerItem.removeObserver(self, forKeyPath: "status")
|
playerItem.removeObserver(self, forKeyPath: "status")
|
||||||
}
|
}
|
||||||
@@ -63,8 +62,8 @@ class ThemeOneVC: UIViewController {
|
|||||||
avPlayer.removeObserver(self, forKeyPath: "timeControlStatus")
|
avPlayer.removeObserver(self, forKeyPath: "timeControlStatus")
|
||||||
avPlayer.pause()
|
avPlayer.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCenter.default.removeObserver(self, name: AVAudioSession.routeChangeNotification, object: nil)
|
NotificationCenter.default.removeObserver(self, name: AVAudioSession.routeChangeNotification, object: nil)
|
||||||
|
// NetworkMonitor.shared.stopMonitoring()
|
||||||
}
|
}
|
||||||
|
|
||||||
override var preferredStatusBarStyle: UIStatusBarStyle {
|
override var preferredStatusBarStyle: UIStatusBarStyle {
|
||||||
@@ -79,13 +78,7 @@ class ThemeOneVC: UIViewController {
|
|||||||
if MyListDataTemp.shareInstance.favListingData?.showData == nil {
|
if MyListDataTemp.shareInstance.favListingData?.showData == nil {
|
||||||
MyListDataTemp.shareInstance.favListingData = FavouriteListingDM.ResultData(totalRecords: nil, showData: FavouriteListingDM.ResultData.ShowData(hindi: [],english: []),videoData: [],gameData: [],singKaraokeData: [],audioData: [])
|
MyListDataTemp.shareInstance.favListingData = FavouriteListingDM.ResultData(totalRecords: nil, showData: FavouriteListingDM.ResultData.ShowData(hindi: [],english: []),videoData: [],gameData: [],singKaraokeData: [],audioData: [])
|
||||||
}
|
}
|
||||||
// NetworkMonitor.shared.startMonitoring()
|
|
||||||
// connectedToNetwork()
|
|
||||||
|
|
||||||
// PersistentStorage.shared.deleteData()
|
|
||||||
// PersistentStorage.shared.retrieveData()
|
|
||||||
vm.setupAvPlayer()
|
vm.setupAvPlayer()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
@@ -160,22 +153,30 @@ class ThemeOneVC: UIViewController {
|
|||||||
// MARK: - Handle Live TV Observer
|
// MARK: - Handle Live TV Observer
|
||||||
|
|
||||||
extension ThemeOneVC{
|
extension ThemeOneVC{
|
||||||
func startMonitoring(){
|
|
||||||
NetworkReachibility.shared.startMonitoring { [weak self] isConnected in
|
func startMonitoringNetwork() {
|
||||||
|
if vm.isNetworkMonitored{return}
|
||||||
|
vm.isNetworkMonitored = true
|
||||||
|
vm.monitor.pathUpdateHandler = { [weak self] path in
|
||||||
guard let self else{return}
|
guard let self else{return}
|
||||||
switch isConnected{
|
if path.status == .satisfied {
|
||||||
case true: // if network is connected than stop
|
|
||||||
// when internet is back we have to setup player again
|
// when internet is back we have to setup player again
|
||||||
NetworkReachibility.shared.stopMonitoring()
|
vm.monitor.cancel()
|
||||||
vm.avPlayer = nil
|
DispatchQueue.main.async {
|
||||||
vm.setupAvPlayer()
|
self.vm.avPlayer = nil
|
||||||
|
self.vm.setupAvPlayer()
|
||||||
|
}
|
||||||
print("network connection is back")
|
print("network connection is back")
|
||||||
case false:
|
} else {
|
||||||
// if there is no internet connection prompt user and show reload icon
|
print("No connection.")
|
||||||
self.toast(msg: "Lost Connection.", time: 1.4)
|
|
||||||
// liveTVActivityIndicator.stopAnimating()
|
|
||||||
}
|
}
|
||||||
|
print("Is on WiFi: \(path.usesInterfaceType(.wifi))")
|
||||||
|
print("Is on Cellular: \(path.usesInterfaceType(.cellular))")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm.monitor.start(queue: vm.queue)
|
||||||
|
vm.isNetworkMonitored = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func addObservers() {
|
func addObservers() {
|
||||||
@@ -199,7 +200,12 @@ extension ThemeOneVC{
|
|||||||
vm.avPlayer.play()
|
vm.avPlayer.play()
|
||||||
} else if vm.playerItem.status == .failed {
|
} else if vm.playerItem.status == .failed {
|
||||||
print("Theme 1 Player failed to load")
|
print("Theme 1 Player failed to load")
|
||||||
vm.setupAvPlayer()
|
/*
|
||||||
|
Check if network is connected.
|
||||||
|
*/
|
||||||
|
if vm.reachability?.isReachable == true{
|
||||||
|
vm.setupAvPlayer()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,6 +216,7 @@ extension ThemeOneVC{
|
|||||||
case .waitingToPlayAtSpecifiedRate:
|
case .waitingToPlayAtSpecifiedRate:
|
||||||
vm.startStopActivity(isStart: true)
|
vm.startStopActivity(isStart: true)
|
||||||
print("Theme 1 Player Buffering...")
|
print("Theme 1 Player Buffering...")
|
||||||
|
|
||||||
switch vm.reachability?.isReachable{
|
switch vm.reachability?.isReachable{
|
||||||
case true:
|
case true:
|
||||||
break
|
break
|
||||||
@@ -218,7 +225,10 @@ extension ThemeOneVC{
|
|||||||
Start monitoring when the player buffers and there is not internet connection
|
Start monitoring when the player buffers and there is not internet connection
|
||||||
*/
|
*/
|
||||||
print("Monitoring Started")
|
print("Monitoring Started")
|
||||||
NetworkMonitor.shared.startMonitoring()
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.4){ [weak self] in
|
||||||
|
guard let self else{return}
|
||||||
|
self.startMonitoringNetwork()
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,16 +98,43 @@ class ThemeTwoVC: UIViewController {
|
|||||||
|
|
||||||
// MARK: - Handler for AvPlayer
|
// MARK: - Handler for AvPlayer
|
||||||
|
|
||||||
|
func startMonitoringNetwork() {
|
||||||
|
if vm.isNetworkMonitored{return}
|
||||||
|
vm.isNetworkMonitored = true
|
||||||
|
vm.monitor.pathUpdateHandler = { [weak self] path in
|
||||||
|
guard let self else{return}
|
||||||
|
if path.status == .satisfied {
|
||||||
|
// when internet is back we have to setup player again
|
||||||
|
vm.monitor.cancel()
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.vm.avPlayer = nil
|
||||||
|
self.vm.setupAvPlayer()
|
||||||
|
}
|
||||||
|
print("network connection is back")
|
||||||
|
} else {
|
||||||
|
print("No connection.")
|
||||||
|
|
||||||
|
}
|
||||||
|
print("Is on WiFi: \(path.usesInterfaceType(.wifi))")
|
||||||
|
print("Is on Cellular: \(path.usesInterfaceType(.cellular))")
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.monitor.start(queue: vm.queue)
|
||||||
|
vm.isNetworkMonitored = true
|
||||||
|
}
|
||||||
|
|
||||||
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
||||||
|
|
||||||
//this will oberver if player loads the url or fails
|
//this will oberver if player loads the url or fails
|
||||||
if keyPath == "status" {
|
if keyPath == "status" {
|
||||||
if vm.playerItem.status == .readyToPlay {
|
if vm.playerItem.status == .readyToPlay {
|
||||||
print("Theme 1 Player is ready to play")
|
print("Theme 2 Player is ready to play")
|
||||||
vm.avPlayer.play()
|
vm.avPlayer.play()
|
||||||
} else if vm.playerItem.status == .failed {
|
} else if vm.playerItem.status == .failed {
|
||||||
print("Theme 1 Player failed to load")
|
print("Theme 2 Player failed to load")
|
||||||
vm.setupAvPlayer()
|
if vm.reachability?.isReachable == true{
|
||||||
|
vm.setupAvPlayer()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,13 +143,28 @@ class ThemeTwoVC: UIViewController {
|
|||||||
if let player = object as? AVPlayer {
|
if let player = object as? AVPlayer {
|
||||||
switch player.timeControlStatus {
|
switch player.timeControlStatus {
|
||||||
case .waitingToPlayAtSpecifiedRate:
|
case .waitingToPlayAtSpecifiedRate:
|
||||||
print("Theme 1 Player Buffering...")
|
print("Theme 2 Player Buffering...")
|
||||||
vm.startStopActivity(isStart: true)
|
vm.startStopActivity(isStart: true)
|
||||||
|
switch vm.reachability?.isReachable{
|
||||||
|
case true:
|
||||||
|
break
|
||||||
|
case false:
|
||||||
|
/*
|
||||||
|
Start monitoring when the player buffers and there is not internet connection
|
||||||
|
*/
|
||||||
|
print("Monitoring Started")
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.4){ [weak self] in
|
||||||
|
guard let self else{return}
|
||||||
|
self.startMonitoringNetwork()
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
case .playing:
|
case .playing:
|
||||||
print("Theme 1 Player Playing")
|
print("Theme 2 Player Playing")
|
||||||
vm.startStopActivity(isStart: false)
|
vm.startStopActivity(isStart: false)
|
||||||
case .paused:
|
case .paused:
|
||||||
print("Theme 1 Player Paused")
|
print("Theme 2 Player Paused")
|
||||||
|
|
||||||
// check if app is in background return it
|
// check if app is in background return it
|
||||||
if UIApplication.shared.applicationState == .background {return}
|
if UIApplication.shared.applicationState == .background {return}
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ class ThemeOneVM{
|
|||||||
|
|
||||||
var shouldAnimate = true
|
var shouldAnimate = true
|
||||||
let reachability = NetworkReachabilityManager()
|
let reachability = NetworkReachabilityManager()
|
||||||
|
let monitor = NWPathMonitor()
|
||||||
|
let queue = DispatchQueue.global(qos: .background)
|
||||||
|
var isNetworkMonitored = false
|
||||||
|
|
||||||
func initView(){
|
func initView(){
|
||||||
AuthFunc.shareInstance.initTimePeriods()
|
AuthFunc.shareInstance.initTimePeriods()
|
||||||
startInitialTimer()
|
startInitialTimer()
|
||||||
@@ -56,28 +59,28 @@ class ThemeOneVM{
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(self.reloadTheme), name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(self.reloadTheme), name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChange(_:)), name: AVAudioSession.routeChangeNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChange(_:)), name: AVAudioSession.routeChangeNotification, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(showOfflineDeviceUI(notification:)), name: NSNotification.Name.connectivityStatus, object: nil)
|
// NotificationCenter.default.addObserver(self, selector: #selector(showOfflineDeviceUI(notification:)), name: NSNotification.Name.connectivityStatus, object: nil)
|
||||||
}
|
|
||||||
|
|
||||||
@objc func showOfflineDeviceUI(notification: Notification) {
|
|
||||||
if NetworkMonitor.shared.isConnected {
|
|
||||||
NetworkMonitor.shared.stopMonitoring()
|
|
||||||
guard let avPlayer else{return}
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
|
||||||
guard let self else{return}
|
|
||||||
if avPlayer.currentItem == nil || avPlayer.currentItem?.status == .failed {
|
|
||||||
print("Player was Nil")
|
|
||||||
setupAvPlayer()
|
|
||||||
} else {
|
|
||||||
print("Player is not Nil")
|
|
||||||
setupAvPlayer()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print("Connected")
|
|
||||||
} else {
|
|
||||||
print("Not connected")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @objc func showOfflineDeviceUI(notification: Notification) {
|
||||||
|
// if NetworkMonitor.shared.isConnected {
|
||||||
|
// NetworkMonitor.shared.stopMonitoring()
|
||||||
|
// guard let avPlayer else{return}
|
||||||
|
// DispatchQueue.main.async { [weak self] in
|
||||||
|
// guard let self else{return}
|
||||||
|
// if avPlayer.currentItem == nil || avPlayer.currentItem?.status == .failed {
|
||||||
|
// print("Player was Nil")
|
||||||
|
// setupAvPlayer()
|
||||||
|
// } else {
|
||||||
|
// print("Player is not Nil")
|
||||||
|
// setupAvPlayer()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// print("Connected")
|
||||||
|
// } else {
|
||||||
|
// print("Not connected")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@objc func handleRouteChange(_ notification: Notification) {
|
@objc func handleRouteChange(_ notification: Notification) {
|
||||||
guard let userInfo = notification.userInfo,
|
guard let userInfo = notification.userInfo,
|
||||||
@@ -349,7 +352,7 @@ class ThemeOneVM{
|
|||||||
self.vc.liveTvPlayer.layer.sublayers?.forEach { $0.removeFromSuperlayer() }
|
self.vc.liveTvPlayer.layer.sublayers?.forEach { $0.removeFromSuperlayer() }
|
||||||
|
|
||||||
self.vc.liveTvPlayer.layer.addSublayer(playerLayer)
|
self.vc.liveTvPlayer.layer.addSublayer(playerLayer)
|
||||||
|
playerLayer.frame = vc.liveTvPlayer.bounds
|
||||||
avPlayer.volume = 0
|
avPlayer.volume = 0
|
||||||
vc.addObservers()
|
vc.addObservers()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
import JWPlayerKit
|
import JWPlayerKit
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
struct Theme2Struct{
|
struct Theme2Struct{
|
||||||
let imageName : String
|
let imageName : String
|
||||||
@@ -22,6 +23,11 @@ class ThemeTwoVM{
|
|||||||
var playerItem: AVPlayerItem!
|
var playerItem: AVPlayerItem!
|
||||||
var playerLayer: AVPlayerLayer!
|
var playerLayer: AVPlayerLayer!
|
||||||
|
|
||||||
|
let reachability = NetworkReachabilityManager()
|
||||||
|
let monitor = NWPathMonitor()
|
||||||
|
let queue = DispatchQueue.global(qos: .background)
|
||||||
|
var isNetworkMonitored = false
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Static cell data
|
Static cell data
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user