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

Exoplayer2 - Move AndroidMediaPlayerImpl creation + Listeners binding to collaborator #43

Merged
merged 8 commits into from
Jun 9, 2017

Conversation

juankysoriano
Copy link
Contributor

Problem

In a previous PR #38 we discussed about removing the setForwarder method from AndroidMediaPlayerFacade

Solution

Done that, what required moving the binding of the listeners done in AndroidMediaPlayerImpl to a collaborator class; AndroidMediaPlayerImplCreator.

Test(s) added

Yes, the AndroidMediaPlayerImplCreator is fully tested, moving the tests existing on AndroidMediaPlayerImpl to it.

Screenshots

No UI changes

Paired with

Nobody, but talked with @joetimmins about a potential solution.

Note In a future PR (if this succeed) I will do the same for ExoPlayer2Impl

@juankysoriano juankysoriano changed the title Exoplayer2 - Move AndroidMediaPlayerImpl creating + Listeners binding to collaborator Exoplayer2 - Move AndroidMediaPlayerImpl creation + Listeners binding to collaborator Jun 8, 2017
@@ -175,11 +108,25 @@ private void requestSurface(SurfaceHolderRequester.Callback callback) {
surfaceHolderRequester.requestSurfaceHolder(callback);
}

void resetSeek() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be methods on the Player interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't be used by any of the clients of Player, and very likely not be needed for the other implementation.

@@ -125,6 +126,7 @@ public void onPrepared(MediaPlayer mp) {
@Override
public void onCompletion(MediaPlayer mp) {
currentState = PlaybackState.COMPLETED;
MediaPlayer.OnCompletionListener onCompletionForwarder = forwarder.onCompletionListener();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we enforce the forwarder's listeners to not be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the question is:

Can the player of the library force this listeners to be null? The question is no, because in the worst case scenario the forwarder will have a no-op implementation contained.

But it is possible that we, developers, by mistake do something that causes it hold a null. You can consider the thrown below as a DeveloperError

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay cool, just wondering! 👍

@joetimmins
Copy link
Contributor

I'm not as up to speed with the exoplayer stuff as other people on the project, but this is an improvement IMO on what was there before. Better separation of concerns between configuring the player impl and using it.

@ouchadam
Copy link
Contributor

ouchadam commented Jun 8, 2017

I'm a fan of the separate creator but not totally sold on the setup happening inside of it.

Would prefer that logic to remain inside the impl under a impl.initialise method which would be used internally via the PlayerFactory

    private Player createMediaPlayer() {
        AndroidMediaPlayerImpl player = androidMediaPlayerImplCreator.create(context);
        player.initialise();
        return player;
    }

what do you think?

@juankysoriano
Copy link
Contributor Author

juankysoriano commented Jun 8, 2017

@ouchadam let me check if that will still remove the original concern: having a setForwarder method on the facade

@juankysoriano
Copy link
Contributor Author

@ouchadam 8195032

@@ -24,36 +24,35 @@
private static final Map<String, String> NO_HEADERS = null;

private final Context context;
private MediaPlayerForwarder forwarder;
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be final 😸


public void initialise() {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@ouchadam
Copy link
Contributor

ouchadam commented Jun 9, 2017

I like it! It's probably worth making a similar change to ExoPlayerImpl as well in another PR 👻

@juankysoriano
Copy link
Contributor Author

Yes I will do it in exoplayer!

@ouchadam ouchadam merged commit 9e2be86 into exo-player-2 Jun 9, 2017
@ouchadam ouchadam deleted the exoplayer2-set-listeners-upon-construction branch June 9, 2017 09:17
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