-
Notifications
You must be signed in to change notification settings - Fork 28
Exoplayer2 - Move AndroidMediaPlayerImpl creation + Listeners binding to collaborator #43
Exoplayer2 - Move AndroidMediaPlayerImpl creation + Listeners binding to collaborator #43
Conversation
@@ -175,11 +108,25 @@ private void requestSurface(SurfaceHolderRequester.Callback callback) { | |||
surfaceHolderRequester.requestSurfaceHolder(callback); | |||
} | |||
|
|||
void resetSeek() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay cool, just wondering! 👍
I'm not as up to speed with the |
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 private Player createMediaPlayer() {
AndroidMediaPlayerImpl player = androidMediaPlayerImplCreator.create(context);
player.initialise();
return player;
} what do you think? |
@ouchadam let me check if that will still remove the original concern: having a |
@@ -24,36 +24,35 @@ | |||
private static final Map<String, String> NO_HEADERS = null; | |||
|
|||
private final Context context; | |||
private MediaPlayerForwarder forwarder; |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I like it! It's probably worth making a similar change to ExoPlayerImpl as well in another PR 👻 |
Yes I will do it in exoplayer! |
Problem
In a previous PR #38 we discussed about removing the
setForwarder
method fromAndroidMediaPlayerFacade
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 onAndroidMediaPlayerImpl
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