Video Player: Add rewind and fast forward buttons
This commit is contained in:
parent
937feddafa
commit
4f6ba23cbf
|
@ -639,17 +639,19 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkFavorite();
|
checkFavorite();
|
||||||
if(controller == null) {
|
if(butPlaybackSpeed != null) {
|
||||||
butPlaybackSpeed.setVisibility(View.GONE);
|
if (controller == null) {
|
||||||
} else {
|
butPlaybackSpeed.setVisibility(View.GONE);
|
||||||
butPlaybackSpeed.setVisibility(View.VISIBLE);
|
|
||||||
if (controller.canSetPlaybackSpeed()) {
|
|
||||||
ViewCompat.setAlpha(butPlaybackSpeed, 1.0f);
|
|
||||||
} else {
|
} else {
|
||||||
ViewCompat.setAlpha(butPlaybackSpeed, 0.5f);
|
butPlaybackSpeed.setVisibility(View.VISIBLE);
|
||||||
|
if (controller.canSetPlaybackSpeed()) {
|
||||||
|
ViewCompat.setAlpha(butPlaybackSpeed, 1.0f);
|
||||||
|
} else {
|
||||||
|
ViewCompat.setAlpha(butPlaybackSpeed, 0.5f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
updateButPlaybackSpeed();
|
||||||
}
|
}
|
||||||
updateButPlaybackSpeed();
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -865,7 +867,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButPlaybackSpeed() {
|
private void updateButPlaybackSpeed() {
|
||||||
if (controller != null) {
|
if (controller != null && butPlaybackSpeed != null) {
|
||||||
butPlaybackSpeed.setText(UserPreferences.getPlaybackSpeed() + "x");
|
butPlaybackSpeed.setText(UserPreferences.getPlaybackSpeed() + "x");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
|
|
||||||
private VideoControlsHider videoControlsHider = new VideoControlsHider(this);
|
private VideoControlsHider videoControlsHider = new VideoControlsHider(this);
|
||||||
|
|
||||||
|
private LinearLayout controls;
|
||||||
private LinearLayout videoOverlay;
|
private LinearLayout videoOverlay;
|
||||||
private AspectRatioVideoView videoview;
|
private AspectRatioVideoView videoview;
|
||||||
private ProgressBar progressIndicator;
|
private ProgressBar progressIndicator;
|
||||||
|
@ -116,6 +117,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
protected void setupGUI() {
|
protected void setupGUI() {
|
||||||
super.setupGUI();
|
super.setupGUI();
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
controls = (LinearLayout) findViewById(R.id.controls);
|
||||||
videoOverlay = (LinearLayout) findViewById(R.id.overlay);
|
videoOverlay = (LinearLayout) findViewById(R.id.overlay);
|
||||||
videoview = (AspectRatioVideoView) findViewById(R.id.videoview);
|
videoview = (AspectRatioVideoView) findViewById(R.id.videoview);
|
||||||
progressIndicator = (ProgressBar) findViewById(R.id.progressIndicator);
|
progressIndicator = (ProgressBar) findViewById(R.id.progressIndicator);
|
||||||
|
@ -259,12 +261,11 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private void showVideoControls() {
|
private void showVideoControls() {
|
||||||
videoOverlay.setVisibility(View.VISIBLE);
|
videoOverlay.setVisibility(View.VISIBLE);
|
||||||
butPlay.setVisibility(View.VISIBLE);
|
controls.setVisibility(View.VISIBLE);
|
||||||
final Animation animation = AnimationUtils.loadAnimation(this,
|
final Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
|
||||||
R.anim.fade_in);
|
|
||||||
if (animation != null) {
|
if (animation != null) {
|
||||||
videoOverlay.startAnimation(animation);
|
videoOverlay.startAnimation(animation);
|
||||||
butPlay.startAnimation(animation);
|
controls.startAnimation(animation);
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= 14) {
|
if (Build.VERSION.SDK_INT >= 14) {
|
||||||
videoview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
videoview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||||
|
@ -273,11 +274,10 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private void hideVideoControls() {
|
private void hideVideoControls() {
|
||||||
final Animation animation = AnimationUtils.loadAnimation(this,
|
final Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
|
||||||
R.anim.fade_out);
|
|
||||||
if (animation != null) {
|
if (animation != null) {
|
||||||
videoOverlay.startAnimation(animation);
|
videoOverlay.startAnimation(animation);
|
||||||
butPlay.startAnimation(animation);
|
controls.startAnimation(animation);
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= 14) {
|
if (Build.VERSION.SDK_INT >= 14) {
|
||||||
int videoviewFlag = (Build.VERSION.SDK_INT >= 16) ? View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION : 0;
|
int videoviewFlag = (Build.VERSION.SDK_INT >= 16) ? View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION : 0;
|
||||||
|
@ -286,7 +286,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
videoOverlay.setFitsSystemWindows(true);
|
videoOverlay.setFitsSystemWindows(true);
|
||||||
}
|
}
|
||||||
videoOverlay.setVisibility(View.GONE);
|
videoOverlay.setVisibility(View.GONE);
|
||||||
butPlay.setVisibility(View.GONE);
|
controls.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,14 +19,41 @@
|
||||||
android:indeterminateOnly="true"
|
android:indeterminateOnly="true"
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
|
|
||||||
<ImageButton
|
<LinearLayout
|
||||||
android:id="@+id/butPlay"
|
android:id="@+id/controls"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/overlay_button_circle_background"
|
android:orientation="horizontal">
|
||||||
android:contentDescription="@string/pause_label"
|
|
||||||
android:src="@drawable/ic_av_pause_circle_outline_80dp" />
|
<ImageButton
|
||||||
|
android:id="@+id/butRev"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:background="@drawable/overlay_button_circle_background"
|
||||||
|
android:contentDescription="@string/pause_label"
|
||||||
|
android:src="@drawable/ic_av_rewind_80dp" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/butPlay"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:background="@drawable/overlay_button_circle_background"
|
||||||
|
android:contentDescription="@string/pause_label"
|
||||||
|
android:src="@drawable/ic_av_pause_circle_outline_80dp" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/butFF"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:background="@drawable/overlay_button_circle_background"
|
||||||
|
android:contentDescription="@string/pause_label"
|
||||||
|
android:src="@drawable/ic_av_fast_forward_80dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/overlay"
|
android:id="@+id/overlay"
|
||||||
|
|
Loading…
Reference in New Issue