Exoplayer: Player.STATE_ENDED event is not getting triggered

Created on 10 Nov 2020  路  12Comments  路  Source: google/ExoPlayer

Trying to upgrade to latest version 2.12.1.
Have made all the required changes as per sample app: https://github.com/google/ExoPlayer/tree/release-v2/demos/main/src/main/java/com/google/android/exoplayer2/demo

I am adding only single MediaItem as per my requirement. But problem is Player.STATE_ENDED is not triggered when video ends. I am blocked on this. Not sure if i am missing something. Can share my player activity if required. Please do the needful.
Just le me know, if i am missing something.

Also, video stops but times keeps running beyond video total duration.

question

Most helpful comment

The EventListener stopped completely listening for me after the last update.

           Player.EventListener ev = new Player.EventListener() {
            @Override
            public void onIsLoadingChanged(boolean isLoading) {
                System.out.println("Loading"+isLoading);
            }

            @Override
            public void onPlaybackStateChanged(int state) {
                    System.out.println("State"+state);
            }

            @Override
            public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
                System.out.println("playWhenReady"+playWhenReady);
                System.out.println("reason"+reason);
            }

            @Override
            public void onIsPlayingChanged(boolean isPlaying) {
                System.out.println("isPlaying"+isPlaying);
            }

            @Override
            public void onPlayerError(ExoPlaybackException error) {
                System.out.println(error.toString());
            }
        };

        player.addListener(ev);

I try to disable the ProgressBar in my player but since last update nothing is triggered in my EventListener. Here is a sample code for debugging. Nothing is triggered, only if I close the player then it outputs:

playWhenReadyfalse
reason1

How I close my player:

         if (player != null) {
            player.stop();

            player.setPlayWhenReady(false);
            player.getPlaybackState();
            player.clearVideoSurface();
            player.setVideoSurfaceHolder(null);
            player.release();

        }
        finish();

All 12 comments

The EventListener stopped completely listening for me after the last update.

           Player.EventListener ev = new Player.EventListener() {
            @Override
            public void onIsLoadingChanged(boolean isLoading) {
                System.out.println("Loading"+isLoading);
            }

            @Override
            public void onPlaybackStateChanged(int state) {
                    System.out.println("State"+state);
            }

            @Override
            public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
                System.out.println("playWhenReady"+playWhenReady);
                System.out.println("reason"+reason);
            }

            @Override
            public void onIsPlayingChanged(boolean isPlaying) {
                System.out.println("isPlaying"+isPlaying);
            }

            @Override
            public void onPlayerError(ExoPlaybackException error) {
                System.out.println(error.toString());
            }
        };

        player.addListener(ev);

I try to disable the ProgressBar in my player but since last update nothing is triggered in my EventListener. Here is a sample code for debugging. Nothing is triggered, only if I close the player then it outputs:

playWhenReadyfalse
reason1

How I close my player:

         if (player != null) {
            player.stop();

            player.setPlayWhenReady(false);
            player.getPlaybackState();
            player.clearVideoSurface();
            player.setVideoSurfaceHolder(null);
            player.release();

        }
        finish();

Can you send us a bug report (using "adb bugreport") and a media test content for which you encounter the issue? If you're unable to share bug reports or test content publicly, please send them to dev.[email protected] using a subject in the format "Issue #8199". The code to the player activity may also be useful.

@kim-vde Details sent to dev.[email protected].

This seems to be a problem with the ads XML. Trying to play the ads in the IMA demo fails with error "The response does not contain any valid ads.".

@kim-vde The issue is happening with sample tag url as well : 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%3Dpremidpost&cmsid=496&vid=short_onecue&correlator=

Reference: https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags

@kim-vde Without Ads, all looks good. But the issue is with ads, and if you will agree, even if there is some issue, Player.STATE_ENDED should be fired when video ends.

Everything is working well for me with the valid ads link you provided. The video ends and the onPlaybackStateChanged event is fired. What exactly do you observe?

But the issue is with ads, and if you will agree, even if there is some issue, Player.STATE_ENDED should be fired when video ends.

Yes, I agree. Actually the event is fired if I try the invalid ads link with another video, or if I try a valid ads link (or no ads) with the video you provided. So it is the video and the invalid ads link together that create the issue.

I'll assign to Andrew, who has much more knowledge about IMA than I do.

@kim-vde Have you checked the same with Post-roll ads?

Yes. The valid ads link I mentioned above has a post-roll ad.

@Manvendra-Jadon If you enable logging (via ImaAdsLoader.Builder.setDebugModeEnabled, or by hardcoding ImaAdsLoader.DEBUG = true on old versions), you can see the IMA SDK logs:

AdEvent: {errorMessage=The response does not contain any valid ads., errorCode=1009, type=adLoadError}

when it tries to load the midroll. The midroll is there (at 00:14:17.056) and the postroll is there too, but the IMA SDK thinks they are not valid for playback. I'm afraid I'm not familiar enough with VAST/VMAP ad serving to debug this further. I suggest checking your ad server configuration carefully to make sure it's serving compatible ads to Android devices for the relevant ad breaks. You could also try loading the XML for the midroll in a browser (using the right user agent) and seeing if there's anything invalid there.

@andrewlewis Thanks.
Will notify our team to check the same.

Was this page helpful?
0 / 5 - 0 ratings