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

Android Exoplayer - Resolved the play and pause issue with the full-screen functionality. #1916

Merged
merged 14 commits into from
Feb 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.view.Window;
import android.view.accessibility.CaptioningManager;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.brentvatne.react.R;
Expand Down Expand Up @@ -296,6 +297,27 @@ public void onClick(View v) {
}
});

//Handling the playButton click event
ImageButton playButton = playerControlView.findViewById(R.id.exo_play);
Copy link
Collaborator

Choose a reason for hiding this comment

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

were these buttons not working before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@benoitdion - It's working before, but it's handled by the player control view by default. But now, I have handled the actions of play and pause of my own to update the "isPause" property.

Copy link
Collaborator

Choose a reason for hiding this comment

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

does this means you're overriding a built-in click listener with the one below or are the player control managing that differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes... I am overriding a built-in click listener...But with the same default logic with additional handling of "ispaused" property.

isPaused = paused; if (player != null) { if (!paused) { startPlayback(); } else { pausePlayback(); } }

In default, it will call startPlayback() and pausePlayback() on play and pause correspondingly

playButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (player != null && player.getPlaybackState() == Player.STATE_ENDED) {
player.seekTo(0);
}
setPausedModifier(false);
}
});

//Handling the pauseButton click event
ImageButton pauseButton = playerControlView.findViewById(R.id.exo_pause);
pauseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setPausedModifier(true);
}
});

//Handling the fullScreenButton click event
FrameLayout fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen_button);
fullScreenButton.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -340,7 +362,7 @@ private void addPlayerControl() {
private void updateFullScreenIcon(Boolean fullScreen) {
if(playerControlView != null && player != null) {
//Play the video whenever the user clicks minimize or maximise button. In order to enable the controls
player.setPlayWhenReady(true);
player.setPlayWhenReady(!isPaused);
ImageView fullScreenIcon = playerControlView.findViewById(R.id.exo_fullscreen_icon);
if (fullScreen) {
fullScreenIcon.setImageResource(R.drawable.fullscreen_shrink);
Expand Down