- made theme 2 banner dynamic, if ad loads then only it will be shown
- made radio ad dynamic, now ad will show up only if ad is received - added a retry count to fm, it will try 4 times to connect to the server if not then showing the reload btn
This commit is contained in:
@@ -31,6 +31,7 @@ class WokaFMVC: UIViewController {
|
||||
|
||||
vm.player?.pause()
|
||||
NotificationCenter.default.removeObserver(self,name: UIApplication.didEnterBackgroundNotification, object: nil)
|
||||
NotificationCenter.default.removeObserver(self,name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||
|
||||
// Deactivate the audio session if needed
|
||||
do {
|
||||
@@ -45,11 +46,14 @@ class WokaFMVC: UIViewController {
|
||||
vm.vc = self
|
||||
vm.initView()
|
||||
NotificationCenter.default.addObserver(self,selector: #selector(appDidEnterBackground),name: UIApplication.didEnterBackgroundNotification,object: nil)
|
||||
NotificationCenter.default.addObserver(self,selector: #selector(appWillEnterForeground),name: UIApplication.willEnterForegroundNotification,object: nil)
|
||||
}
|
||||
|
||||
// MARK: - App LifeCycle HAndler
|
||||
|
||||
@objc func appDidEnterBackground() {
|
||||
vm.setupNowPlayingInfo()
|
||||
vm.setupRemoteCommandCenter()
|
||||
if let postID = AuthFunc.shareInstance.staticURLs?.liveFmData?.id {
|
||||
let duration = DateFormatterLib.dateDifferenceINT(date1: vm.startTimeStamp, date2: Date())
|
||||
AuthFunc.shareInstance.userVideoView(postID: postID, postType: PostType.FM.rawValue, duration: duration, catID: 0) { [weak self] isDone in
|
||||
@@ -61,6 +65,10 @@ class WokaFMVC: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
@objc func appWillEnterForeground(){
|
||||
vm.stopMPNowPlayin()
|
||||
}
|
||||
|
||||
@IBAction func playBtnTapped(_ sender: UIButton) {
|
||||
PersistentStorage.shared.addRadioCount()
|
||||
if sender == playBtn{
|
||||
@@ -151,6 +159,12 @@ class WokaFMVC: UIViewController {
|
||||
print("FM is ready to play")
|
||||
vm.player.play()
|
||||
} else if vm.playerItem.status == .failed {
|
||||
if vm.retryCount < 4{
|
||||
vm.retryCount += 1
|
||||
vm.retryConnect()
|
||||
print("retry fm connect :-", vm.retryCount)
|
||||
return
|
||||
}
|
||||
print("FM failed to load")
|
||||
activityIndicator.stopAnimating()
|
||||
playBtn.setImage(UIImage(named: "Reload"), for: .normal)
|
||||
@@ -225,9 +239,10 @@ extension UIButton {
|
||||
extension WokaFMVC : GADBannerViewDelegate{
|
||||
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
|
||||
print("bannerViewDidReceiveAd")
|
||||
adView.isHidden = false
|
||||
bannerView.alpha = 0
|
||||
bannerView.backgroundColor = #colorLiteral(red: 0.01960784314, green: 0, blue: 0.2196078431, alpha: 1)
|
||||
UIView.animate(withDuration: 0.3, animations: {
|
||||
UIView.animate(withDuration: 0.2, animations: {
|
||||
bannerView.alpha = 1
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user