Baseflow / ExoPlayerXamarin

Xamarin bindings library for the Google ExoPlayer library
https://baseflow.com
MIT License
152 stars 67 forks source link

Add IPlayerEventListener to ExoPlayer cause the app crash. #134

Closed unamed000 closed 1 year ago

unamed000 commented 1 year ago

🐛 Bug Report

When i add Add IPlayerEventListener to ExoPlayer, it cause the app crashing without any stack trace.

Expected behavior

It shouldn't crash

Reproduction steps

class LifeCloudDefaultEventListener : Java.Lang.Object, IPlayerEventListener
        {
            private readonly ExoPlayerVideoViewRenderer _renderer;

            public LifeCloudDefaultEventListener(ExoPlayerVideoViewRenderer renderer)
            {
                _renderer = renderer;
            }

            public void OnPlayerStateChanged(bool playWhenReady, int state)
            {
                var mediaState = MediaElementState.Closed;

                switch (state)
                {
                    case IPlayer.StateBuffering:
                        mediaState = MediaElementState.Buffering;
                        break;
                    case IPlayer.StateIdle:
                        mediaState = MediaElementState.Opening;
                        break;
                    case IPlayer.StateReady:
                        mediaState = playWhenReady ? MediaElementState.Playing : MediaElementState.Paused;
                        break;
                    case IPlayer.StateEnded:
                        mediaState = MediaElementState.Stopped;
                        break;
                }

                _renderer.NotifyState(mediaState);
            }
        }

Configuration

Version: 2.11.8

Platform:

ScriptSun commented 1 year ago

@martijn00 Can you release an update for it using the new IPlayer.IListener because the interface is crashing now its buggy

doughouzlight commented 1 year ago

strange its the mots important function in all exoplayer and yet we are here

ArchangelWTF commented 1 year ago

The same fix I've used https://github.com/Baseflow/ExoPlayerXamarin/issues/137#issuecomment-1316642086 here should apply, though as the version is a bit older perhaps you'd have to implement some different form of methods.