Delay control hiding when button pressed
This commit is contained in:
parent
acff2ba0d6
commit
8f3f0c30c6
|
@ -763,8 +763,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
|
||||
if (butRev != null) {
|
||||
butRev.setOnClickListener(v -> {
|
||||
int curr = controller.getPosition();
|
||||
controller.seekTo(curr - UserPreferences.getRewindSecs() * 1000);
|
||||
onRewind();
|
||||
});
|
||||
butRev.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
|
||||
|
@ -800,12 +799,13 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
});
|
||||
}
|
||||
|
||||
butPlay.setOnClickListener(controller.newOnPlayButtonClickListener());
|
||||
butPlay.setOnClickListener(v -> {
|
||||
onPlayPause();
|
||||
});
|
||||
|
||||
if (butFF != null) {
|
||||
butFF.setOnClickListener(v -> {
|
||||
int curr = controller.getPosition();
|
||||
controller.seekTo(curr + UserPreferences.getFastFowardSecs() * 1000);
|
||||
onFastForward();
|
||||
});
|
||||
butFF.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
|
||||
|
@ -848,6 +848,29 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
}
|
||||
}
|
||||
|
||||
protected void onRewind() {
|
||||
if (controller == null) {
|
||||
return;
|
||||
}
|
||||
int curr = controller.getPosition();
|
||||
controller.seekTo(curr - UserPreferences.getRewindSecs() * 1000);
|
||||
}
|
||||
|
||||
protected void onPlayPause() {
|
||||
if(controller == null) {
|
||||
return;
|
||||
}
|
||||
controller.playPause();
|
||||
}
|
||||
|
||||
protected void onFastForward() {
|
||||
if (controller == null) {
|
||||
return;
|
||||
}
|
||||
int curr = controller.getPosition();
|
||||
controller.seekTo(curr + UserPreferences.getFastFowardSecs() * 1000);
|
||||
}
|
||||
|
||||
protected abstract int getContentViewResourceId();
|
||||
|
||||
void handleError(int errorCode) {
|
||||
|
|
|
@ -202,6 +202,24 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
|||
videoControlsShowing = !videoControlsShowing;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRewind() {
|
||||
super.onRewind();
|
||||
setupVideoControlsToggler();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPlayPause() {
|
||||
super.onPlayPause();
|
||||
setupVideoControlsToggler();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFastForward() {
|
||||
super.onFastForward();
|
||||
setupVideoControlsToggler();
|
||||
}
|
||||
|
||||
|
||||
private final SurfaceHolder.Callback surfaceHolderCallback = new SurfaceHolder.Callback() {
|
||||
@Override
|
||||
|
|
|
@ -72,7 +72,11 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
controller = setupPlaybackController();
|
||||
butPlay.setOnClickListener(controller.newOnPlayButtonClickListener());
|
||||
butPlay.setOnClickListener(v -> {
|
||||
if(controller != null) {
|
||||
controller.playPause();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private PlaybackController setupPlaybackController() {
|
||||
|
@ -88,7 +92,6 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
return butPlay;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean loadMediaInfo() {
|
||||
ExternalPlayerFragment fragment = ExternalPlayerFragment.this;
|
||||
|
@ -145,8 +148,11 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
}
|
||||
controller = setupPlaybackController();
|
||||
if (butPlay != null) {
|
||||
butPlay.setOnClickListener(controller
|
||||
.newOnPlayButtonClickListener());
|
||||
butPlay.setOnClickListener(v -> {
|
||||
if(controller != null) {
|
||||
controller.playPause();
|
||||
}
|
||||
});
|
||||
}
|
||||
controller.init();
|
||||
}
|
||||
|
|
|
@ -574,8 +574,7 @@ public abstract class PlaybackController {
|
|||
|
||||
}
|
||||
|
||||
public OnClickListener newOnPlayButtonClickListener() {
|
||||
return v -> {
|
||||
public void playPause() {
|
||||
if (playbackService == null) {
|
||||
Log.w(TAG, "Play/Pause button was pressed, but playbackservice was null!");
|
||||
return;
|
||||
|
@ -601,7 +600,6 @@ public abstract class PlaybackController {
|
|||
playbackService.prepare();
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean serviceAvailable() {
|
||||
|
|
Loading…
Reference in New Issue