eneim / toro

Video list auto playback made simple, specially built for RecyclerView
Apache License 2.0
1.42k stars 253 forks source link

Question: Support for ExoPlayer IMA extension #358

Open smithc42 opened 6 years ago

smithc42 commented 6 years ago

Hi, I was wondering if Toro supports ad playback using the ExoPlayer IMA extension?

Thanks!

eneim commented 6 years ago

Theoretically it should support this by default. Let me try this later.

smithc42 commented 6 years ago

Great! If you have any questions let me know

smithc42 commented 6 years ago

@eneim hey, just wondering if you got a chance to try this? I'd like to try it myself or implement the extension if possible. If you have any idea on where to start that'd be great!

smithc42 commented 6 years ago

Hey, I've tried to get the IMA extension working with Toro. I've created a module (toro-exoplayer-ima) which is basically a copy of the existing toro-exoplayer module, except it uses AdsMediaSource.

The Facebook IMA Timeline Demo I updated is successfully playing IMA ads. The issue I'm having is that when the video with an advert goes off screen and then re-appears on screen (scroll down the back up) the advert disappears and video playback resumes. The advert should resume playback from where it stopped.

If I comment the line playbackInfo.setResumeWindow(player.getCurrentWindowIndex());, the pre-roll video plays again but from the start, and the video loses it's previous position.

I have a feeling the issue might be due to the player view instance being cached (it's passed to the AdsMediaSource here).

Do you have any suggestions on what I could try?

Thanks!

eneim commented 6 years ago

Hi @smithc42, thanks a lot for your input. I will need more time to look into this, hope you can wait. toro-exoplayer is created with composition in mind, what I thought is you can create a custom Config, and feed it a custom MediaSourceCreator (or Factory) that build AdsMediaSource, it may work. Since I have not tried it yet, I will take your input and update whatever it requires.

eneim commented 6 years ago

@smithc42 I have put some updates to latest dev-v3, you can get it using version 3.6.0.2802-SNAPSHOT, there is also demo code at demo-ads. Please take a look :D.

smithc42 commented 6 years ago

@eneim thanks for the update!

I had a quick test of the demo-ads module and the ads play, but there's the same issue I faced previously with the ad not resuming when the video comes back on screen.

The issue I'm having is that when the video with an advert goes off screen and then re-appears on screen (scroll down the back up) the advert disappears and video playback resumes. The advert should resume playback from where it stopped.

Steps to reproduce

  1. Play first video with ad
  2. Scroll to second video before ad finishes on first video
  3. Second video with ad starts playing
  4. Scroll back to first video

Expected result:

Ad resumes playback at position it stopped on first video

Actual result

Ad stops playing before it completes and video content continues playback

eneim commented 6 years ago

I see. I will see what I can do, but it seems to be a ongoing issue with ExoPlayer too: https://github.com/google/ExoPlayer/issues/4300 and we may need to wait ^^!

smithc42 commented 6 years ago

Ah, ok. Hopefully they look into the fixing the bug at some stage! Thanks

eneim commented 6 years ago

@smithc42 So I take a look at the IMA Doc. If we intercept the AdEvent and make some customize, it may work: https://developers.google.com/interactive-media-ads/docs/sdks/android/v3/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventType

Honestly, I don't really understand how Ads should work in practice (there are many patterns ...). If you can take a look on this Doc, and give me some input I can consider to make it as Beta testing. For example, "considering a certain AdEvent has passed, then what kind of behaviour should be done" kind of thing :D.

smithc42 commented 6 years ago

So after adding an AdEventListener to the ImaAdsLoader in the demo-ads sample, I can see when order of AdEvents.

Currently

  1. Play first video with ad : AdEventType.STARTED on first video
  2. Scroll to second video before ad finishes on first video : AdEventType.PAUSED on first video
  3. Second video with ad starts playing : AdEventType.STARTED on second video
  4. (1) Scroll back to first video : AdEventType.PAUSED on second video
  5. (2) Scroll back to first video (No event passed; video plays but ad does not resume)

Expected

  1. Play first video with ad : AdEventType.STARTED on first video
  2. Scroll to second video before ad finishes on first video: AdEventType.PAUSED on first video
  3. Second video with ad starts playing: AdEventType.STARTED on second video
  4. (1) Scroll back to first video : AdEventType.PAUSED on second video
  5. (2) Scroll back to first video : AdEventType.RESUMED on first video

Thanks!

shalom365 commented 6 years ago

Hi, Do you manage to show ima ads? or the bug still accures? I tried to use im.ene.toro3:toro:3.6.0.2802-SNAPSHOT in order to try implementing ima ads and I could not sync gradle.

Thanks!

eneim commented 6 years ago

@shalom365 Please try to refresh cache to something to make it syncs ... And see if it works for you.