Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Provide both Surface and SurfaceHolder in MediaPlayer #162

Merged
merged 5 commits into from
Jun 13, 2018

Conversation

JozefCeluch
Copy link
Contributor

Problem

While adding a support for TextureView I (possibly) changed the behavior of MediaPlayer with the SurfaceView because instead of providing SurfaceHolder to MediaPlayer I started providing Surface. I don't know if that changes any behavior, so it's probably for the best to keep the changes to minimum.

Solution

Add support to provide both Surface and SurfaceHolder to MediaPlayer by introducing a concept of Either. That way, the Surface is only provided if no-player is used with TextureView which is completely separate from the previous SurfaceView behavior that uses SurfaceHolder.

Test(s) added

updated and added where necessary

Screenshots

no UI changes

Paired with

nobody

mediaPlayer.setDisplay(value);
}
};
surface.apply(setSurface, setDisplay);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really digging this 👍

@@ -0,0 +1,50 @@
package com.novoda.noplayer.model;
Copy link
Contributor

@ouchadam ouchadam Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we exposing this to clients? If not the project is using the convention of an internal package to describe public classes which do not provide a guaranteed api.

Copy link
Contributor Author

@JozefCeluch JozefCeluch Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly, but it's used in SurfaceRequester which is kinda exposed in the public API through PlayerSurfaceHolder(the clients need to provide an instance of this when they implement a custom implementation of PlayerView).

@@ -67,7 +68,7 @@ static AndroidMediaPlayerFacade newInstance(Context context, MediaPlayerForwarde
this.mediaPlayerCreator = mediaPlayerCreator;
}

void prepareVideo(Uri videoUri, Surface surface) {
public void prepareVideo(Uri videoUri, Either<Surface, SurfaceHolder> surface) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this public was done in error, the class is still package.

Copy link
Contributor

@Mecharyry Mecharyry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a public method that shouldn't be then LGTM 💯

@Mecharyry Mecharyry merged commit 4780a8d into develop Jun 13, 2018
@Mecharyry Mecharyry deleted the media_player_surface_holder branch June 13, 2018 13:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants