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

SimpleExoPlayer.setVideoListener() causes rendering issues r2.1.1 #2286

Closed
pilzflorian opened this issue Jan 3, 2017 · 3 comments
Closed
Labels

Comments

@pilzflorian
Copy link

Setting SimpleExoPlayer.VideoListener() causes rendering issues (SimpleExoPlayerView does not show any frames). audio plays fine and even the VideoListener's are invoked properly. Am I missing something here?
Following code illustrates the problem.

   private void playStream(final Uri mediaUrl) {
        Log.d(LOGTAG, "Now playing: " + mediaUrl);
        mUrl.setText(mediaUrl.toString());
        // Measures bandwidth during playback. Can be null if not required.
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        // Produces DataSource instances through which media data is loaded.
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "yourApplicationName"), bandwidthMeter);
        // Produces Extractor instances for parsing the media data.
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        // This is the MediaSource representing the media to be played.
        MediaSource videoSource;
        if(mediaUrl.getLastPathSegment().contains(".m3u8"))
            videoSource = new HlsMediaSource(mediaUrl,dataSourceFactory, 10, null, null);
        else
            videoSource = new ExtractorMediaSource(mediaUrl,dataSourceFactory, extractorsFactory, null, null);
        // Following listener breaks rendering
        player.setVideoListener(new SimpleExoPlayer.VideoListener() {
            @Override
            public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
                Log.e(LOGTAG, "onVideoSizeChanged: " + width + ":" +height);
            }

            @Override
            public void onRenderedFirstFrame() {
                Log.e(LOGTAG, "onRenderedFirstFrame ");
            }
        });
        // Prepare the player with the source.
        player.prepare(videoSource);
        player.setPlayWhenReady(true);
    }

Replacing setVideoListener() with setVideoDebugListener() solves the issue.
Tested on Nexus 9 running 7.0

@pilzflorian pilzflorian changed the title SimpleExoPlayer.SimplesetVideoListener() causes rendering issues r2.1.1 SimpleExoPlayer.Simple.setVideoListener() causes rendering issues r2.1.1 Jan 3, 2017
@pilzflorian pilzflorian changed the title SimpleExoPlayer.Simple.setVideoListener() causes rendering issues r2.1.1 SimpleExoPlayer.setVideoListener() causes rendering issues r2.1.1 Jan 3, 2017
@ojw28
Copy link
Contributor

ojw28 commented Jan 3, 2017

SimpleExoPlayerView registers itself as the video listener, so when you set it you're replacing SimpleExoPlayerView as the listener. Hence SimpleExoPlayerView doesn't receive the events that it needs.

Why do you need to register a video listener when also using SimpleExoPlayerView?

@ojw28 ojw28 added the question label Jan 3, 2017
@pilzflorian
Copy link
Author

Thank you so much for clarification, I will create my own SurfaceView and Controller instances.
I need the information for gathering QOS statistics.
I'll close this, thanks again for the quick response!

@ojw28
Copy link
Contributor

ojw28 commented Jan 4, 2017

You should use setVideoDebugListener to gather QOS statistics, and let the view use setVideoListener.

@google google locked and limited conversation to collaborators Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants