iOS SDK fails to replace currentItem for AVPlayer

646 views
Skip to first unread message

davidl...@gmail.com

unread,
Dec 17, 2018, 8:24:13 AM12/17/18
to Interactive Media Ads SDK
  1. Which SDK are you using : IMA SDK 3.8.1
  2. What ad tag are you using in your request: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21707087615/PrerollAd&description_url=http%3A%2F%2Fsporttotal.tv&env=vp&impl=s&correlator=\(Int(arc4random_uniform(99_999)))&tfcd=0&npa=0&gdfp_req=1&output=vast&sz=400x300%7C640x480%7C1280x720%7C1920x1080&unviewed_position_start=1"
  3. Are you able to reproduce this issue using your ad tag in the sample app (AndroidiOS) or the Video Suite Inspector (HTML5Flash): Sporttotal iOS APP starting from v. 3.0 (https://itunes.apple.com/us/app/sporttotal/id1133608797)
  4. What steps must we take to reproduce your issue: start the app, navigate to "Replays", start video. While pre-roll add is playing tap on Related items, pre-roll add should start again, tap on related item again.

Hi there! I've had posted the issue previously here (https://groups.google.com/forum/#!topic/ima-sdk/hCn5QHXPFZc), now getting back to it with more details. So basically the error I was getting is appearing in following scenario: you have a AVPlayer initialised only once, as well as the AdsPlayer. Then you start a video, and pre-roll starts to play. While preroll is playing, user is able to switch video, so the  avPlayer?.currentItem
 will change. What happens is you are calling `avPlayer.replaceCurrentItem(with: avItem)`  and then requesting ads:

    func requestAds(with parameters: DFPAdParameters?) {


        log.debug("Request ads")


        if adsManager != nil {


            adsManager?.pause()


            adsManager?.destroy()


        }


       


        let adURLString = parameters.flatMap({ parameters in


            guard var urlComponents = URLComponents(string: AdsPlayer.currentPrerollUrl) else { return nil }


            urlComponents.queryItems = (urlComponents.queryItems ?? []) + [parameters.query]


                return urlComponents.url?.absoluteString


        }) ?? AdsPlayer.currentPrerollUrl




        // Create ad display container for ad rendering.


        let adDisplayContainer = IMAAdDisplayContainer(adContainer: videoView, companionSlots: nil)


        // Create an ad request with our ad tag, display container, and optional user context.


        let request = IMAAdsRequest(adTagUrl: adURLString,


                                    adDisplayContainer: adDisplayContainer,


                                    avPlayerVideoDisplay: IMAAVPlayerVideoDisplay(avPlayer: avPlayer),


                                    pictureInPictureProxy: pictureInPictureProxy,


                                    userContext: nil)


       


        adsLoader.requestAds(with: request)


       


        _ = NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification,


                                                   object: nil, queue: nil) { [weak self] (_) in


                                                    if self?.adStatus == .playing {


                                                        self?.adsManager?.resume()


                                                    }


        }


       


        _ = NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification,


                                                   object: nil, queue: nil) { [weak self] (_) in


                                                    if self?.adStatus == .playing {


                                                        self?.adsManager?.pause()


                                                    }


        }


    }


The problem appears when you do this 3-7 times while pre-roll ads are displayed. At some point when IMAAdsLoader or IMAAdsManager receives error  avPlayer?.currentItem is set to nil, and the avPlayer is set to waitingToPlayAtSpecifiedRate with AVPlayerWaitingWithNoItemToPlayReason.  I have to manually replace avPlayer?.currentItem with the same AVItem.

But that's the first question. The second is that if I put the adsLoader.contentComplete() before requesting adds the same add will be played while switching items again and again. If I remove contentComplete I will get a new (different) add when switching videos, and at some point I will get an ERROR: failed loading ads due to: The VAST response document is empty.  Now I'm not sure whether I should call a contentComplete() in this scenario? Technically content has not completed, it has not even started yet.

davidl...@gmail.com

unread,
Dec 21, 2018, 4:10:55 AM12/21/18
to Interactive Media Ads SDK
Any answer here? Still getting the issue, here's more logs I can provide:
You can see that it fails immediately 

09:58:36 AdsPlayer.adsLoader() 💚 DEBUG: loaded finished loading data: Optional(<IMAAdsLoadedData: 0x281bff2a0>)

09:58:36 AdsPlayer.adsManager() 💚 DEBUG: Ads manager did receive event: Loaded

09:58:36 AdsPlayer.adsManagerDidRequestContentPause() 💚 DEBUG: Ads manager:Optional(<IMAAdsManager: 0x283983610>) DidRequestContentPause for player: Optional(<AVPlayer: 0x2818c3580>)

09:58:36 VideoPlayer.playerStatus() 💚 DEBUG: Regular: paused -> paused

09:58:36 VideoPlayer.playerStatus() 💚 DEBUG: Regular: paused -> paused

09:58:37 VideoPlayer.init() 💚 DEBUG: CurrentItem changed:

https://d2rfgtg6ekc16k.cloudfront.net/wige/5abb730e1b6f1daf072bfc31/hd-copied.mp4 ->

 https://redirector.gvt1.com/api/manifest/hls_variant/requiressl/yes/source/gfp_video_ads/id/d027b273025fd846/itag/0/playlist_type/LIVE/acao/yes/mime/application%2Fx-mpegURL/ctier/L/ip/0.0.0.0/ipbits/0/expire/1576918716/sparams/ip,ipbits,expire,requiressl,source,id,itag,playlist_type,acao,mime,ctier/signature/8BADBFD807FF985D4F83EAAA47CAD3E16B3B306A.3BDC7830BF753CB215701F7324CEC00EAA11F12E/key/ck2/file/index.m3u8

09:58:37 VideoPlayer.playerStatus() 💚 DEBUG: Regular: paused -> paused

09:58:38 VideoPlayer.videoIsBuffering() 💚 DEBUG: Regular: true -> false

09:58:38 VideoPlayer.videoIsBuffering() 💚 DEBUG: Panorama: true -> false

09:58:38 VideoPlayer.playerStatus() 💚 DEBUG: Regular: paused -> waitingToPlayAtSpecifiedRate

09:58:38 VideoPlayer.playerStatus() 💚 DEBUG: Reason: AVPlayerWaitingReason(_rawValue: AVPlayerWaitingWhileEvaluatingBufferingRateReason)

09:58:38 VideoPlayer.playerStatus() 💚 DEBUG: Regular: waitingToPlayAtSpecifiedRate -> playing

09:58:38 AdsPlayer.adsManager() 💚 DEBUG: Ads manager did receive event: Started

09:58:41 AdsPlayer.adsManager() 💚 DEBUG: Ads manager did receive event: First Quartile

09:58:44 AdsPlayer.adsManager() 💚 DEBUG: Ads manager did receive event: Midpoint

09:58:46 AdsPlayer.adsManager() 💚 DEBUG: Ads manager did receive event: Third Quartile

09:58:49 DividerPlayer.playerItemFinished() 💚 DEBUG: Now

09:58:49 VideoPlayer.init() 💚 DEBUG: CurrentItem changed:

https://redirector.gvt1.com/api/manifest/hls_variant/requiressl/yes/source/gfp_video_ads/id/d027b273025fd846/itag/0/playlist_type/LIVE/acao/yes/mime/application%2Fx-mpegURL/ctier/L/ip/0.0.0.0/ipbits/0/expire/1576918716/sparams/ip,ipbits,expire,requiressl,source,id,itag,playlist_type,acao,mime,ctier/signature/8BADBFD807FF985D4F83EAAA47CAD3E16B3B306A.3BDC7830BF753CB215701F7324CEC00EAA11F12E/key/ck2/file/index.m3u8 ->

 https://d2rfgtg6ekc16k.cloudfront.net/wige/5abb730e1b6f1daf072bfc31/hd-copied.mp4

09:58:49 VideoPlayer.playerStatus() 💚 DEBUG: Regular: playing -> playing

09:58:58 VideoPlayer.playerStatus() 💚 DEBUG: Regular: playing -> paused

09:58:58 AdsPlayer.adsManager() 💚 DEBUG: Ads manager did receive event: Complete

09:58:58 AdsPlayer.adsManagerDidRequestContentResume() 💚 DEBUG: Ads manager:Optional(<IMAAdsManager: 0x283983610>) DidRequestContentResume for player: Optional(<AVPlayer: 0x2818c3580>)

09:59:02 VideoPlayer.playerStatus() 💚 DEBUG: Regular: paused -> waitingToPlayAtSpecifiedRate

09:59:02 VideoPlayer.playerStatus() 💚 DEBUG: Reason: AVPlayerWaitingReason(_rawValue: AVPlayerWaitingWhileEvaluatingBufferingRateReason)

09:59:02 VideoPlayerViewController+StatusHandler.playerStatusChanged() ❤️ ERROR: avItemStatus: 2, playerStatus: waitingToPlayAtSpecifiedRate, avPlayer error:Optional(Error Domain=AVFoundationErrorDomain Code=-11819 "Vorgang kann nicht abgeschlossen werden" UserInfo={NSLocalizedDescription=Vorgang kann nicht abgeschlossen werden, NSLocalizedRecoverySuggestion=Später erneut versuchen.}), avItemError: Optional(Error Domain=AVFoundationErrorDomain Code=-11819 "Vorgang kann nicht abgeschlossen werden" UserInfo={NSLocalizedDescription=Vorgang kann nicht abgeschlossen werden, NSLocalizedRecoverySuggestion=Später erneut versuchen.}), avItemErrorLog: nil

Reply all
Reply to author
Forward
0 new messages