-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Getting Error, Ads not working. #8152
Comments
You are trying to pass an ad tag URI as if it was a I think you can fix this by using the IMA extension. The relevant code snippets in https://exoplayer.dev/ad-insertion.html#declarative-ad-support are:
... where you can pass your ad tag URI, and:
For this one your Side note: I think the confusion comes from the fact that the ad insertion documentation describes how to do ad insertion yourself (here) without using the IMA extension, but for that part of the instructions you'd need to get the actual ad media URLs, rather than just the ad tag URI from which they can be loaded. So I'm suggesting above you just use the IMA extension as it takes care of this for you. |
IMA extension dependencies so it can’t be import module lonely. How I can run. ImaAdsLoader should come from extension but its taking from library.
Thanks
ZN
… On 03-Nov-2020, at 5:40 PM, Andrew Lewis ***@***.***> wrote:
IMA extension
|
I'm afraid I don't understand. Please could you rephrase, or paste the error you are seeing? When you depend on |
Error
2020-11-03 19:24:12.847 25446-25787/com.e.medrecexoplayer E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:554)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:201)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor) could read the stream.
at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1024)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
2020-11-03 19:24:12.849 25446-25446/com.e.medrecexoplayer E/error: Source error
Build.gradle
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.google.android.exoplayer:exoplayer:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-core:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.0'
implementation 'com.google.android.exoplayer:extension-ima:2.12.0'
}
Java Code
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
MediaSourceFactory mediaSourceFactory =
new DefaultMediaSourceFactory(this)
.setAdsLoaderProvider(this::getAdsLoader)
.setAdViewProvider(playerView);
// Create a SimpleExoPlayer and set is as the player for content and ads.
player = new SimpleExoPlayer.Builder(this).setMediaSourceFactory(mediaSourceFactory).build();
playerView.setPlayer(player);
// Set PlayWhenReady. If true, content and ads autoplay.
player.setPlayWhenReady(true);
// A pre-roll ad.
MediaItem preRollAd = MediaItem.fromUri("https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpostpodbumper&cmsid=496&vid=short_onecue&correlator=");
// The start of the content.
MediaItem contentStart =
new MediaItem.Builder()
.setUri(getString(R.string.content_url))
.setClipEndPositionMs(120_000)
.build();
// A mid-roll ad.
MediaItem midRollAd = MediaItem.fromUri("https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpostpodbumper&cmsid=496&vid=short_onecue&correlator=");
// The rest of the content
MediaItem contentEnd =
new MediaItem.Builder()
.setUri(getString(R.string.content_url))
.setClipStartPositionMs(120_000)
.build();
// Build the playlist.
player.addMediaItem(preRollAd);
player.addMediaItem(contentStart);
player.addMediaItem(midRollAd);
player.addMediaItem(contentEnd);
// Prepare the content and ad to be played with the SimpleExoPlayer.
player.prepare();
player.play();
player.addListener(new Player.EventListener() {
@OverRide
public void onPlayerError(ExoPlaybackException error) {
Log.e("error", error.getMessage());
}
});
// Set PlayWhenReady. If true, content and ads autoplay.
// player.setPlayWhenReady(true);
Thanks
ZN
… On 03-Nov-2020, at 6:52 PM, Andrew Lewis ***@***.***> wrote:
Reopened #8152 <#8152>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#8152 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AREMPN7SAOEYAOJSHRNJONDSN77X5ANCNFSM4TISQUEQ>.
|
My first comment explains the
I don't understand what this means. Please could you try rephrasing it? |
Thanks…. I have made the changes and its working now. But I have few questions.
#1 How I can control the ad numbers as I am getting sometimes 2 and sometimes 3 ads in a sequence.
#2 How I can control the position of the ads (On start, in mid of video or in last of video)
#3 When I am trying to add another media item then I am getting below crash.
2020-11-03 19:50:10.396 4644-4644/com.e.medrecexoplayer E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.e.medrecexoplayer, PID: 4644
java.lang.IllegalStateException
at com.google.android.exoplayer2.ExoPlayerImpl.validateMediaSources(ExoPlayerImpl.java:1133)
at com.google.android.exoplayer2.ExoPlayerImpl.addMediaSources(ExoPlayerImpl.java:421)
at com.google.android.exoplayer2.ExoPlayerImpl.addMediaItems(ExoPlayerImpl.java:400)
at com.google.android.exoplayer2.ExoPlayerImpl.addMediaItems(ExoPlayerImpl.java:395)
at com.google.android.exoplayer2.BasePlayer.addMediaItem(BasePlayer.java:65)
at com.google.android.exoplayer2.SimpleExoPlayer.addMediaItem(SimpleExoPlayer.java:1531)
at com.e.medrecexoplayer.PlayVideo.initializePlayer(PlayVideo.java:90)
at com.e.medrecexoplayer.PlayVideo.onStart(PlayVideo.java:126)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1392)
at android.app.Activity.performStart(Activity.java:7252)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2970)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Thanks
ZN
… On 03-Nov-2020, at 7:31 PM, Andrew Lewis ***@***.***> wrote:
My first comment explains the UnrecognizedInputFormatException. You need to remove the code that passes the ad tag URI and use the code I provided there instead.
IMA extension dependencies so it can’t be import module lonely. How I can run. ImaAdsLoader should come from extension but its taking from library.
I don't understand what this means. Please could you try rephrasing it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#8152 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AREMPNYXOHCB3BYHLO5XROLSOAELFANCNFSM4TISQUEQ>.
|
These are controlled by your ad tag, so please configure the behavior you need on your ads server.
Playing ads with |
Can we reduce late ad load latency?
Can we load ad on first screen and show on next screen?
Please let me know if it is possible?
Thanks
ZN
… On 03-Nov-2020, at 8:34 PM, Andrew Lewis ***@***.***> wrote:
How I can control the ad numbers as I am getting sometimes 2 and sometimes 3 ads in a sequence.
How I can control the position of the ads (On start, in mid of video or in last of video)
These are controlled by your ad tag, so please configure the behavior you need on your ads server.
When I am trying to add another media item then I am getting below crash.
Playing ads with `ImaAdsLoader in playlists is not currently supported, but will be supported soon. Please follow #3750 <#3750> for updates.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#8152 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AREMPN6Y32JPR74PU3STOULSOALXNANCNFSM4TISQUEQ>.
|
You can call construct the ImaAdsLoader and call |
Hi,
I have done the requestAds but still its taking around 3+ seconds for the first time launch of ad. We need to cache the ad. Please have a look on attached java file for your reference.
Thanks in Advance.
… On 04-Nov-2020, at 2:16 AM, Andrew Lewis ***@***.***> wrote:
You can call construct the ImaAdsLoader and call imaAdsLoader.requestAds to request the ad tag before preparing the player (mentioned in #3636 <#3636>).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#8152 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AREMPNZW4N7QQCRT42LO7ADSOBT3RANCNFSM4TISQUEQ>.
|
I am waiting for revert as I need to release build. Please have a look on java code and let me know what’s he issue. I need to prefetch the video ad and when user click on button, It should start instantly.
Thanks
… On 04-Nov-2020, at 8:16 PM, ZAHID NAQVI ***@***.***> wrote:
Hi,
I have done the requestAds but still its taking around 3+ seconds for the first time launch of ad. We need to cache the ad. Please have a look on attached java file for your reference.
Thanks in Advance.
<PlayVideo.java>
> On 04-Nov-2020, at 2:16 AM, Andrew Lewis ***@***.*** ***@***.***>> wrote:
>
>
> You can call construct the ImaAdsLoader and call imaAdsLoader.requestAds to request the ad tag before preparing the player (mentioned in #3636 <#3636>).
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub <#8152 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AREMPNZW4N7QQCRT42LO7ADSOBT3RANCNFSM4TISQUEQ>.
>
|
Can you create the player before the user clicks the button but call |
Thanks a lot for your kind help. Issue has been resolved. You can close this ticket. Thanks
|
Java Code
MediaSourceFactory mediaSourceFactory =
new DefaultMediaSourceFactory(this)
.setAdsLoaderProvider(this::getAdsLoader)
.setAdViewProvider(playerView);
// Create a SimpleExoPlayer and set is as the player for content and ads.
player = new SimpleExoPlayer.Builder(this).setMediaSourceFactory(mediaSourceFactory).build();
playerView.setPlayer(player);
//adsLoader.setPlayer(player);
// DataSource.Factory dataSourceFactory =
// new DefaultDataSourceFactory(this, Util.getUserAgent(this,
// getString(R.string.app_name)));
// ProgressiveMediaSource.Factory mediaSourceFactory =
// new ProgressiveMediaSource.Factory(dataSourceFactory);
// Create the MediaSource for the content you wish to play.
// MediaSource mediaSource =
// mediaSourceFactory.createMediaSource(Uri.parse(getString(R.string.content_url)));
// Create the AdsMediaSource using the AdsLoader and the MediaSource.
//AdsMediaSource adsMediaSource =
// new AdsMediaSource(mediaSource, dataSourceFactory, adsLoader, playerView);
// Prepare the content and ad to be played with the SimpleExoPlayer.
// player.prepare(adsMediaSource);
// Set PlayWhenReady. If true, content and ads autoplay.
player.setPlayWhenReady(true);
// A pre-roll ad.
MediaItem preRollAd = MediaItem.fromUri("https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpostpodbumper&cmsid=496&vid=short_onecue&correlator=");
// The start of the content.
MediaItem contentStart =
new MediaItem.Builder()
.setUri(getString(R.string.content_url))
.setClipEndPositionMs(120_000)
.build();
// A mid-roll ad.
MediaItem midRollAd = MediaItem.fromUri("https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpostpodbumper&cmsid=496&vid=short_onecue&correlator=");
// The rest of the content
MediaItem contentEnd =
new MediaItem.Builder()
.setUri(getString(R.string.content_url))
.setClipStartPositionMs(120_000)
.build();
// Build the playlist.
player.addMediaItem(preRollAd);
player.addMediaItem(contentStart);
player.addMediaItem(midRollAd);
player.addMediaItem(contentEnd);
// Prepare the content and ad to be played with the SimpleExoPlayer.
player.prepare();
player.play();
player.addListener(new Player.EventListener() {
@OverRide
public void onPlayerError(ExoPlaybackException error) {
Log.e("errpr", error.getMessage());
}
});
// Set PlayWhenReady. If true, content and ads autoplay.
// player.setPlayWhenReady(true);
Error log
2020-11-03 16:07:07.300 10637-10682/com.e.medrecexoplayer E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:554)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor) could read the stream.
at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1024)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2020-11-03 16:07:07.302 10637-10637/com.e.medrecexoplayer E/errpr: Source error
Build Gradle
implementation 'com.google.android.exoplayer:exoplayer:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-core:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.0'
implementation 'com.google.android.exoplayer:extension-ima:2.12.0'
The text was updated successfully, but these errors were encountered: