Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting currentTime during an AD_BREAK_END event does not work #223

Closed
webnard opened this issue Oct 30, 2023 · 2 comments
Closed

Setting currentTime during an AD_BREAK_END event does not work #223

webnard opened this issue Oct 30, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@webnard
Copy link
Contributor

webnard commented Oct 30, 2023

I am testing IMA ads on iOS and trying to implement a workaround for #207. The player ignores setting the currentTime value during an AD_BREAK_END AD_EVENT callback.

  const onPlayerReady = async (p: THEOplayer) => {
    p.addEventListener(PlayerEventType.AD_EVENT, function (event: AdEvent) {
      if (event.subType === AdEventType.AD_BREAK_END) {
        p.currentTime = 35000 // is ignored
      }
    });
@tvanlaerhoven tvanlaerhoven added the bug Something isn't working label Nov 6, 2023
@wvanhaevre
Copy link
Collaborator

Setting the currentTime on the AdEvent indeed 'is ignored' as the player is still in the context of playing the ad. You are receiving the adBreakEnd event at the time the ad has finished playing, but the player has not yet switched back to the main content. Setting the currentTime at this time is still trying to change the timeValue for the ad.

I quickly did a test on native iOS and noticed that you could for example use the CAN_PLAY event. And could combine this with a boolean that indicates an AdBreak just ended.

For example: (swift code from iOS test)

self.canPlayListener = player.addEventListener(type: PlayerEventTypes.CAN_PLAY) { event in
            if self.adEnded {
                player.currentTime = 60
                self.adEnded = false
            }
}

where you set self.adEnded on the AdBreakEnd event:

self.adBreakEndListener = player.ads.addEventListener(type: AdsEventTypes.AD_BREAK_END) { event in
            self.adEnded = true
}

On RN the same flow should do the trick

@webnard
Copy link
Contributor Author

webnard commented Nov 7, 2023

Thanks, @wvanhaevre. This works. :)

@webnard webnard closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants