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 work with SimpleExoPlayerView #2240

Closed
darktiny opened this issue Dec 21, 2016 · 9 comments
Closed

SimpleExoPlayer work with SimpleExoPlayerView #2240

darktiny opened this issue Dec 21, 2016 · 9 comments

Comments

@darktiny
Copy link

I want to get video's size through SimpleExoPlayer.VideoListener, then change SimpleExoPlayerView's resizeMode dynamically. Currently it's impossible.

Here's the code

SimpleExoPlayer player;
SimpleExoPlayerView playerView;
VideoListener listener;

...

playerView.setPlayer(player);  // will call player's setVideoListener
player.setVideoListener(listener) // will replace the previous one

since SimpleExoPlayer's VideoListener is not exposed, there's no way to reach the goal except reflection

ExoPlayer version: 2.1.1

@lioun1729
Copy link

resizeMode means resolution shows user in device monitor?

or video frame?

if the latter, I think video frame's size is dependent on encoder

so it can't change

It is only my opinion, other person comment please if i was wrong about this issue

@ojw28
Copy link
Contributor

ojw28 commented Dec 29, 2016

  • As it happens there's also SimpleExoPlayer.setVideoDebugListener, which receives changes in the video size as well. It's not really intended to be used this way, but you could probably use it to do what you want.
  • I can't really think of a valid reason for setting the resize mode dynamically; it doesn't sound right. Can you explain what you're trying to achieve? If you really do need to do this then it's likely we just need to add another resize mode that does what you need directly, so that you don't have to mess about changing it dynamically.

@darktiny
Copy link
Author

@ojw28 What I need is centerCrop resize mode just like android's ImageView.

@ojw28
Copy link
Contributor

ojw28 commented Jan 2, 2017

I don't think the approach in your pull request is the best way to achieve this. I have a feeling it might not always work properly, but I don't have any hard data confirming this yet.

In any case, if you're using SimpleExoPlayer and SimpleExoPlayerView in their default configuration (i.e. the video is being rendered to a SurfaceView), then you should use SimpleExoPlayer.setVideoScalingMode to achieve this. The value you need to pass is C. VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING. You should set the resizeMode of the SimpleExoPlayerView to fit.

@darktiny
Copy link
Author

darktiny commented Jan 4, 2017

@ojw28 I have tried your advice, it doesn't work.

     /**
     * The content is scaled, maintaining its aspect ratio, the whole
     * surface area is used, content may be cropped.
     * <p class=note>
     * This mode is only suitable for content with 1:1 pixel aspect ratio as you cannot
     * configure the pixel aspect ratio for a {@link Surface}.
     * <p class=note>
     * As of {@link android.os.Build.VERSION_CODES#N} release, this mode may not work if
     * the video is {@linkplain MediaFormat#KEY_ROTATION rotated} by 90 or 270 degrees.
     */
    public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING = 2;

@ojw28
Copy link
Contributor

ojw28 commented Jan 4, 2017

What does "doesn't work" mean exactly? It should work. Setting resizeMode to fit should make the view the correct size at least. What are you seeing being drawn into the view if not cropped video?

@darktiny
Copy link
Author

darktiny commented Jan 4, 2017

@ojw28 just video with black edges

@ojw28
Copy link
Contributor

ojw28 commented Jan 9, 2017

resizeMode actually needs setting to fill rather than fit. I then see expected behavior on Pixel, but not on the emulator. Does it work for you?

@darktiny
Copy link
Author

@ojw28 it works, thanks for your help

@ojw28 ojw28 closed this as completed Jan 10, 2017
@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.
Projects
None yet
Development

No branches or pull requests

3 participants