Can I play ads in the period of
See original GitHub issueHello and thanks for your time…
The required fields are below, but here’s a short introduction:
I started to develop a new app - I have to admit that I am new to android app and exoplayer but have experience as a java developer - for an android TV-Box (beelink GT1) that downloads media to a SD Card (short videos of 2 to 10 minutes in length), plays it 24/7 and the playback is interrupted every 10 minutes to play a sequence of adverts no matter what media source is currently playing or at what position the currently played media source is at. It just keeps spamming adverts in a defined rhythm. Streaming the media is not an option since I have to deal with different bandwidths at the different box locations and sometimes even offline operating boxes (therefore the idea to download the media and saving it to the external storage before/while playing it).
My first idea was to create a ConcatenatingMediaSource and take this “playlist” as “contentMediaSource” parameter for my AdsMediaSource. But this lead to the following error:
E/AndroidRuntime: FATAL EXCEPTION: ExoPlayerImplInternal:Handler
Process: com.airtango.lpsplayer, PID: 8711
java.lang.IllegalArgumentException
at com.google.android.exoplayer2.util.Assertions.checkArgument(Assertions.java:39)
at com.google.android.exoplayer2.source.ads.AdsMediaSource.onContentSourceInfoRefreshed(AdsMediaSource.java:329)
at com.google.android.exoplayer2.source.ads.AdsMediaSource.onChildSourceInfoRefreshed(AdsMediaSource.java:303)
at com.google.android.exoplayer2.source.ads.AdsMediaSource.onChildSourceInfoRefreshed(AdsMediaSource.java:55)
at com.google.android.exoplayer2.source.CompositeMediaSource.lambda$prepareChildSource$0$CompositeMediaSource(CompositeMediaSource.java:97)
at com.google.android.exoplayer2.source.-$$Lambda$CompositeMediaSource$ahAPO18YbnzL6kKRAWdp4FR_Vco.onSourceInfoRefreshed(lambda)
at com.google.android.exoplayer2.source.BaseMediaSource.refreshSourceInfo(BaseMediaSource.java:74)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.updateTimelineAndScheduleOnCompletionActions(ConcatenatingMediaSource.java:705)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.handleMessage(ConcatenatingMediaSource.java:675)
at com.google.android.exoplayer2.source.ConcatenatingMediaSource.lambda$fl0myfoK2raBckmHYwV9YTd0eeo(ConcatenatingMediaSource.java)
at com.google.android.exoplayer2.source.-$$Lambda$ConcatenatingMediaSource$fl0myfoK2raBckmHYwV9YTd0eeo.handleMessage(lambda)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Google searches brought me to the issue 3750 saying that I …
… can’t compose it with other media sources as ImaAdsLoader’s logic makes assumptions about the player timeline when it handles player events, and these assumptions may be incorrect if the player is actually playing a concatenation.
My case is a bit different though and here I am asking the question…
[REQUIRED] Searched documentation and issues
- Timeline, Period and Window Docs (https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/Timeline.html)
- Issues concerning ConcatenatingMediaSource and AdsMediaSource #3750 #3636
[REQUIRED] Question
How can I play a series of short video clips of content media in a everlasting loop - I can do that already with ConcatenatingMediaSource and player.setRepeatMode(…) , but now comes the point where I struggle - and interrupt the playback with ads every 5 minutes?
So basically I want my playlist to be interrupted with ads and not the single clips the playlist is built on. I tried my best to explain my situation and I am happy to answer any questions you may have to understand and maybe help me with my problem.
Thanks alreay! Cheers, Clement
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top GitHub Comments
Hi @cle-bo
With regards to the question
my understanding is that you have a predefined list of items and want to play an ad at predefined 5 minute intervals. You may achieve this by concatenating a series of ClippingMediaSources for the main content and regular media sources for your ad content:
There are two caveats here:
@cle-bo it sounds like you have a very controlled environment. Please make sure to re-test anytime you change a parameter on your setup (video/audio formats, device firmware and/or android version).
Closing this as it seems the issue at hand has been answered.