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

IPlayerEventListener on android #79

Closed
nikolaypopadiuk opened this issue Dec 19, 2018 · 13 comments
Closed

IPlayerEventListener on android #79

nikolaypopadiuk opened this issue Dec 19, 2018 · 13 comments

Comments

@nikolaypopadiuk
Copy link

💬 Questions and Help

Hello. how possible implement IPlayerEventListener on android?
on official documentation http://google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer2/Player.EventListener.html it's contains many methods, but I don't see it on xamarin. Also in your simple https://github.com/martijn00/ExoPlayerXamarin/blob/4a5110d2695663be138150df43fbbeeb644331c1/Samples/Main/PlayerActivity.cs I see commented code too

@autosoftmultimedia
Copy link

Same issue.
I'm looking for this because RenderedFirstFrame for SimpleExoPlayer is no longer available.

@thomashagstrom
Copy link

Implement the interface and optionally act on the events. Here's ours:

        public void OnLoadingChanged(bool isLoading)
        {
            Console.WriteLine("Loading changed");
        }

        public void OnPlaybackParametersChanged(PlaybackParameters p0)
        {
            this._mediaPlayer.PlaybackParameters = p0;
        }

        public void OnPlayerError(ExoPlaybackException ex)
        {
            this.OnMediaFileFailed(new MediaFileFailedEventArgs(ex, this.CurrentFile));
        }

        private DateTimeOffset LastEnded { get; set; }

        private Guid testGuid { get; set; }

        public void OnPlayerStateChanged(bool playWhenReady, int state)
        {
            this.testGuid = Guid.NewGuid();
            if (state == Player.StateEnded)
            {
                if (this.LastEnded.AddSeconds(3) < DateTimeOffset.Now)
                {
                    this.LastEnded = DateTimeOffset.Now;
                    this.OnMediaFinished(new MediaFinishedEventArgs(this.CurrentFile));
                }
            }
            else if (state == Player.StateBuffering)
            {
                var status = this.GetStatusByIntValue(state);
                var compatState = this.GetCompatValueByStatus(status);
                this.SessionManager.UpdatePlaybackState(compatState, this.Position.Seconds);
                this.CheckStuck(state, this.testGuid);
            }
            else
            {
                var status = this.GetStatusByIntValue(state);
                var compatState = this.GetCompatValueByStatus(status);
                this.SessionManager.UpdatePlaybackState(compatState, this.Position.Seconds);
            }
        }

        public void OnPositionDiscontinuity(int p0)
        {
        }

        public void OnRepeatModeChanged(int p0)
        {
        }

        public void OnSeekProcessed()
        {
        }

        public void OnShuffleModeEnabledChanged(bool p0)
        {
        }

        public void OnTimelineChanged(Timeline p0, Object p1, int p2)
        {
        }

        public void OnTracksChanged(TrackGroupArray p0, TrackSelectionArray p1)
        {
        }

@marufbd
Copy link

marufbd commented Mar 17, 2019

My code is like:

_player = ExoPlayerFactory.NewSimpleInstance(_ctx, new DefaultTrackSelector(adaptiveVideoTrackSelector));
_player.AddListener(this);
_player.PlayWhenReady = true;


@thomashagstrom
Implemented all methods as per your suggestion.

Which gives the following error:

03-17 09:36:31.151: E/AndroidRuntime(7036): java.lang.AbstractMethodError: abstract method "void com.google.android.exoplayer2.Player$EventListener.onPlayerStateChanged(boolean, int)"

@thomashagstrom
Copy link

@marufbd would need a bit more of the stacktrace. What's the actual error? Missing, null reference etc?

@marufbd
Copy link

marufbd commented Mar 19, 2019

@thomashagstrom whole of stacktrace:

03-20 01:06:38.033: E/AndroidRuntime(17966): java.lang.AbstractMethodError: abstract method "void com.google.android.exoplayer2.Player$EventListener.onPlayerStateChanged(boolean, int)"
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.notifyListeners(ExoPlayerImpl.java:802)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:716)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at com.google.android.exoplayer2.ExoPlayerImpl.setPlayWhenReady(ExoPlayerImpl.java:248)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at com.google.android.exoplayer2.SimpleExoPlayer.updatePlayWhenReady(SimpleExoPlayer.java:1185)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at com.google.android.exoplayer2.SimpleExoPlayer.setPlayWhenReady(SimpleExoPlayer.java:892)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at md58432a647068b097f9637064b8985a5e0.FragmentContainer.n_onCreateView(Native Method)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at md58432a647068b097f9637064b8985a5e0.FragmentContainer.onCreateView(FragmentContainer.java:33)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.Fragment.performCreateView(Fragment.java:2261)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1819)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2590)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2377)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2332)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2239)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.os.Handler.handleCallback(Handler.java:751)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.os.Handler.dispatchMessage(Handler.java:95)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.os.Looper.loop(Looper.java:154)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at android.app.ActivityThread.main(ActivityThread.java:6682)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at java.lang.reflect.Method.invoke(Native Method)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
03-20 01:06:38.033: E/AndroidRuntime(17966): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

@marufbd
Copy link

marufbd commented Mar 26, 2019

I think Player.EventListener has got default methods which Xamarin.Binding does not support yet
dotnet/java-interop#341

@zoriya
Copy link

zoriya commented Jun 4, 2019

Does anybody find a way to use the event listener ? When I create the methods, they are never called.

@martijn00
Copy link
Collaborator

You need to set the dex compiler to d8 in the android options so java 1.8 support is enabled.

@PawKanarek
Copy link

@martijn00 I have set the d8 dex compiler, but events from IPlayerEventListener are not firing anyway. Why did you close issue?

@zoriya
Copy link

zoriya commented Jun 13, 2019

For me the app builds and the exoplayer is working as intended (with the last version and with d8 enabled). But the event listener is never triggered. The interface seem empty, there is no methods in it so the events are not triggered.

1 similar comment
@haohighview
Copy link

For me the app builds and the exoplayer is working as intended (with the last version and with d8 enabled). But the event listener is never triggered. The interface seem empty, there is no methods in it so the events are not triggered.

@yaliashkevich
Copy link

yaliashkevich commented Feb 24, 2021

Actually, there is no way to override IPlayerEventListener methods. It doesn't related to d8. This makes whole this binding project useless.

@yaliashkevich
Copy link

Actually, there is no way to override IPlayerEventListener methods. It doesn't related to d8. This makes whole this binding project useless.

Actually you can, but you have to implement every single method from IPlayerEventListener interface, for some reason default implementation causes AbstractMethodError exception, so it looks to be no sense in such default implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants