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

The surface show nothing after mSimpleExoPlayer.setVideoListener(mVideoListener); #2800

Closed
songwenju opened this issue May 10, 2017 · 9 comments

Comments

@songwenju
Copy link

songwenju commented May 10, 2017

when I use the simpExoPlayer to setVideoListener(videoListener),like this :

mExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exoView);
mExoPlayerView.setPlayer(mSimpleExoPlayer);
mSimpleExoPlayer.setVideoListener(mVideoListener);
mSimpleExoPlayer.addListener(eventListener);
mSimpleExoPlayer.setPlayWhenReady(true);

//the videoLister
 private SimpleExoPlayer.VideoListener mVideoListener = new SimpleExoPlayer.VideoListener() {
        @Override
        public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
            LogUtil.i(this,"MainActivity.onVideoSizeChanged.width:"+width+", height:"+height);

        }

        @Override
        public void onRenderedFirstFrame() {
                LogUtil.i(this,"MainActivity.onRenderedFirstFrame.");
        }
    };

the surface is black ,but audio is play.

@AquilesCanta
Copy link
Contributor

Is there a shutter involved? If so, are you making it invisible? If there is a SimpleExoPlayerView involved, maybe you should also add mExoPlayerView.onRenderedFirstFrame();. Like in:

@Override
public void onRenderedFirstFrame() {
    mExoPlayerView.onRenderedFirstFrame();
    LogUtil.i(this,"MainActivity.onRenderedFirstFrame.");
}

@ojw28
Copy link
Contributor

ojw28 commented May 10, 2017

The problem is that SimpleExoPlayerView sets itself as the video listener (in its setPlayer method), and relies on being the registered listener. By calling setVideoListener yourself you're replacing the listener with your own. SimpleExoPlayerView then doesn't get the events that it needs.

We could change setVideoListener to addVideoListener/removeViewListener if you have a legitimate use case for needing to listen to the events. Normally, though, I'd only expect the player view to need these events.

@ojw28
Copy link
Contributor

ojw28 commented May 10, 2017

Marking as needs-more-info to clarify what the use case is for needing these events.

@songwenju
Copy link
Author

@AquilesCanta

mExoPlayerView.onRenderedFirstFrame();

The object can not use the method.

@AquilesCanta
Copy link
Contributor

Yes, looking into it into detail I noticed the class that actually implements VideoListener is an internal class, not actually SimpleExoPlayerView so the approach I presented won't work. Please reply @ojw28's comment above, so we might think about multiple listeners support.

@songwenju
Copy link
Author

@ojw28 Sometimes I need to monitor the changes in the listener, such as in the TIF, TvInputService want to get the size of the player changes, and then notify the corresponding surface to make the appropriate changes.

@ojw28
Copy link
Contributor

ojw28 commented May 12, 2017

Using setVideoListener is appropriate for that use case. But in that use case it doesn't make sense for you to also be using SimpleExoPlayerView. Either the output is SimpleExoPlayerView (in which case it's the registered video listener) or you're outputting to some other Surface (in which case you're the registered video listener). So I don't think your use case requires the ability to have multiple video listeners simultaneously on the player...

@marcbaechinger
Copy link
Contributor

marcbaechinger commented May 14, 2017

We could change setVideoListener to addVideoListener/removeViewListener if you have a legitimate use case for needing to listen to the events.

@ojw28 I think a legitimate use case could be performance monitoring. While the SimpleExoPlayerView needs the onRenderedFirstFrame to remove the shutter, a performance monitoring listener wants to know the time it takes until the first frame is rendered and report that time.

On the other hand there is also simpleExoPlayer.setVideoDebugListener which allows to set a VideoRendererEventListener which has a onRenderedFirstFrame(Surface surface) callback which is quite the same thing.

@ojw28
Copy link
Contributor

ojw28 commented May 15, 2017

Right, the debug listener is suitable for that case. Closing this for now.

@ojw28 ojw28 closed this as completed May 15, 2017
ojw28 added a commit that referenced this issue Aug 10, 2017
We've seen more than one issue filed where a developer has
registered a video listener and been confused by the fact
their SimpleExoPlayerView no longer works properly. There
are also valid use cases for having multiple metadata/text
outputs.

Issue: #2933
Issue: #2800
Issue: #2286
Issue: #2240

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164839882
ojw28 added a commit that referenced this issue Sep 6, 2017
We've seen more than one issue filed where a developer has
registered a video listener and been confused by the fact
their SimpleExoPlayerView no longer works properly. There
are also valid use cases for having multiple metadata/text
outputs.

Issue: #2933
Issue: #2800
Issue: #2286
Issue: #2240

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164839882
ojw28 added a commit that referenced this issue Sep 9, 2017
We've seen more than one issue filed where a developer has
registered a video listener and been confused by the fact
their SimpleExoPlayerView no longer works properly. There
are also valid use cases for having multiple metadata/text
outputs.

Issue: #2933
Issue: #2800
Issue: #2286
Issue: #2240

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164839882
@google google locked and limited conversation to collaborators Sep 13, 2017
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants