From ee031843ef50000326e8cb6b927d76be4d3a9b8c Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 10 Jan 2016 17:15:52 +0100 Subject: Add icons --- .../main/res/drawable-hdpi/ic_av_fast_forward_80dp.png | Bin 0 -> 1228 bytes core/src/main/res/drawable-hdpi/ic_av_rewind_80dp.png | Bin 0 -> 1277 bytes .../main/res/drawable-mdpi/ic_av_fast_forward_80dp.png | Bin 0 -> 760 bytes core/src/main/res/drawable-mdpi/ic_av_rewind_80dp.png | Bin 0 -> 853 bytes .../main/res/drawable-xhdpi/ic_av_fast_forward_80dp.png | Bin 0 -> 1968 bytes core/src/main/res/drawable-xhdpi/ic_av_rewind_80dp.png | Bin 0 -> 1992 bytes .../main/res/drawable-xxhdpi/ic_av_fast_forward_80dp.png | Bin 0 -> 3207 bytes core/src/main/res/drawable-xxhdpi/ic_av_rewind_80dp.png | Bin 0 -> 3502 bytes .../res/drawable-xxxhdpi/ic_av_fast_forward_80dp.png | Bin 0 -> 5878 bytes core/src/main/res/drawable-xxxhdpi/ic_av_rewind_80dp.png | Bin 0 -> 6299 bytes 10 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 core/src/main/res/drawable-hdpi/ic_av_fast_forward_80dp.png create mode 100755 core/src/main/res/drawable-hdpi/ic_av_rewind_80dp.png create mode 100755 core/src/main/res/drawable-mdpi/ic_av_fast_forward_80dp.png create mode 100755 core/src/main/res/drawable-mdpi/ic_av_rewind_80dp.png create mode 100755 core/src/main/res/drawable-xhdpi/ic_av_fast_forward_80dp.png create mode 100755 core/src/main/res/drawable-xhdpi/ic_av_rewind_80dp.png create mode 100755 core/src/main/res/drawable-xxhdpi/ic_av_fast_forward_80dp.png create mode 100755 core/src/main/res/drawable-xxhdpi/ic_av_rewind_80dp.png create mode 100755 core/src/main/res/drawable-xxxhdpi/ic_av_fast_forward_80dp.png create mode 100755 core/src/main/res/drawable-xxxhdpi/ic_av_rewind_80dp.png diff --git a/core/src/main/res/drawable-hdpi/ic_av_fast_forward_80dp.png b/core/src/main/res/drawable-hdpi/ic_av_fast_forward_80dp.png new file mode 100755 index 000000000..a32968a19 Binary files /dev/null and b/core/src/main/res/drawable-hdpi/ic_av_fast_forward_80dp.png differ diff --git a/core/src/main/res/drawable-hdpi/ic_av_rewind_80dp.png b/core/src/main/res/drawable-hdpi/ic_av_rewind_80dp.png new file mode 100755 index 000000000..e39de4dcf Binary files /dev/null and b/core/src/main/res/drawable-hdpi/ic_av_rewind_80dp.png differ diff --git a/core/src/main/res/drawable-mdpi/ic_av_fast_forward_80dp.png b/core/src/main/res/drawable-mdpi/ic_av_fast_forward_80dp.png new file mode 100755 index 000000000..69b81c10d Binary files /dev/null and b/core/src/main/res/drawable-mdpi/ic_av_fast_forward_80dp.png differ diff --git a/core/src/main/res/drawable-mdpi/ic_av_rewind_80dp.png b/core/src/main/res/drawable-mdpi/ic_av_rewind_80dp.png new file mode 100755 index 000000000..5355abfd6 Binary files /dev/null and b/core/src/main/res/drawable-mdpi/ic_av_rewind_80dp.png differ diff --git a/core/src/main/res/drawable-xhdpi/ic_av_fast_forward_80dp.png b/core/src/main/res/drawable-xhdpi/ic_av_fast_forward_80dp.png new file mode 100755 index 000000000..ed34e22a1 Binary files /dev/null and b/core/src/main/res/drawable-xhdpi/ic_av_fast_forward_80dp.png differ diff --git a/core/src/main/res/drawable-xhdpi/ic_av_rewind_80dp.png b/core/src/main/res/drawable-xhdpi/ic_av_rewind_80dp.png new file mode 100755 index 000000000..3dc7bf5cb Binary files /dev/null and b/core/src/main/res/drawable-xhdpi/ic_av_rewind_80dp.png differ diff --git a/core/src/main/res/drawable-xxhdpi/ic_av_fast_forward_80dp.png b/core/src/main/res/drawable-xxhdpi/ic_av_fast_forward_80dp.png new file mode 100755 index 000000000..f90617f45 Binary files /dev/null and b/core/src/main/res/drawable-xxhdpi/ic_av_fast_forward_80dp.png differ diff --git a/core/src/main/res/drawable-xxhdpi/ic_av_rewind_80dp.png b/core/src/main/res/drawable-xxhdpi/ic_av_rewind_80dp.png new file mode 100755 index 000000000..81709e0ae Binary files /dev/null and b/core/src/main/res/drawable-xxhdpi/ic_av_rewind_80dp.png differ diff --git a/core/src/main/res/drawable-xxxhdpi/ic_av_fast_forward_80dp.png b/core/src/main/res/drawable-xxxhdpi/ic_av_fast_forward_80dp.png new file mode 100755 index 000000000..c9b68abf0 Binary files /dev/null and b/core/src/main/res/drawable-xxxhdpi/ic_av_fast_forward_80dp.png differ diff --git a/core/src/main/res/drawable-xxxhdpi/ic_av_rewind_80dp.png b/core/src/main/res/drawable-xxxhdpi/ic_av_rewind_80dp.png new file mode 100755 index 000000000..87b0756eb Binary files /dev/null and b/core/src/main/res/drawable-xxxhdpi/ic_av_rewind_80dp.png differ -- cgit v1.2.3 From 937feddafa307ec8f8a07634166fe5a35ef5fc13 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 10 Jan 2016 17:17:12 +0100 Subject: Refactor --- .../antennapod/activity/MediaplayerActivity.java | 23 ++- .../antennapod/activity/VideoplayerActivity.java | 177 +++++++++------------ app/src/main/res/layout/videoplayer_activity.xml | 4 +- .../core/util/playback/PlaybackController.java | 75 ++++----- 4 files changed, 121 insertions(+), 158 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 1778bffb1..396adbd81 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -672,12 +672,13 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O return; } + String length; if (showTimeLeft) { - txtvLength.setText("-" + Converter.getDurationStringLong((media - .getDuration() - media.getPosition()))); + length = "-" + Converter.getDurationStringLong(media.getDuration() - media.getPosition()); } else { - txtvLength.setText(Converter.getDurationStringLong((media.getDuration()))); + length = Converter.getDurationStringLong(media.getDuration()); } + txtvLength.setText(length); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(PREF_SHOW_TIME_LEFT, showTimeLeft); @@ -765,8 +766,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O if (rewindSecs == values[i]) { checked = i; } - choices[i] = String.valueOf(values[i]) + " " - + getString(R.string.time_seconds); + choices[i] = String.valueOf(values[i]) + " " + getString(R.string.time_seconds); } choice = values[checked]; AlertDialog.Builder builder = new AlertDialog.Builder(MediaplayerActivity.this); @@ -807,8 +807,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O if (rewindSecs == values[i]) { checked = i; } - choices[i] = String.valueOf(values[i]) + " " - + getString(R.string.time_seconds); + choices[i] = String.valueOf(values[i]) + " " + getString(R.string.time_seconds); } choice = values[checked]; AlertDialog.Builder builder = new AlertDialog.Builder(MediaplayerActivity.this); @@ -854,15 +853,13 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O float prog; @Override - public void onProgressChanged(SeekBar seekBar, int progress, - boolean fromUser) { + public void onProgressChanged (SeekBar seekBar,int progress, boolean fromUser) { if (controller != null) { - prog = controller.onSeekBarProgressChanged(seekBar, progress, fromUser, - txtvPosition); + prog = controller.onSeekBarProgressChanged(seekBar, progress, fromUser, txtvPosition); if (showTimeLeft && prog != 0) { int duration = controller.getDuration(); - txtvLength.setText("-" + Converter - .getDurationStringLong(duration - (int) (prog * duration))); + String length = "-" + Converter.getDurationStringLong(duration - (int) (prog * duration)); + txtvLength.setText(length); } } } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index 60eb290b5..8d5ca5403 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -3,9 +3,9 @@ package de.danoeh.antennapod.activity; import android.annotation.SuppressLint; import android.content.Intent; import android.graphics.drawable.ColorDrawable; -import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; +import android.os.Handler; import android.support.v4.view.WindowCompat; import android.util.Log; import android.util.Pair; @@ -19,7 +19,8 @@ import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.SeekBar; -import de.danoeh.antennapod.BuildConfig; +import java.lang.ref.WeakReference; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.service.playback.PlaybackService; @@ -39,7 +40,8 @@ public class VideoplayerActivity extends MediaplayerActivity { */ private boolean videoControlsShowing = true; private boolean videoSurfaceCreated = false; - private VideoControlsHider videoControlsToggler; + + private VideoControlsHider videoControlsHider = new VideoControlsHider(this); private LinearLayout videoOverlay; private AspectRatioVideoView videoview; @@ -60,26 +62,13 @@ public class VideoplayerActivity extends MediaplayerActivity { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0x80000000)); } - @Override - protected void onPause() { - super.onPause(); - if (videoControlsToggler != null) { - videoControlsToggler.cancel(true); - } - if (controller != null && controller.getStatus() == PlayerStatus.PLAYING) { - controller.pause(); - } - } - @Override protected void onResume() { super.onResume(); if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_VIEW)) { Intent intent = getIntent(); - if (BuildConfig.DEBUG) - Log.d(TAG, "Received VIEW intent: " - + intent.getData().getPath()); + Log.d(TAG, "Received VIEW intent: " + intent.getData().getPath()); ExternalMedia media = new ExternalMedia(intent.getData().getPath(), MediaType.VIDEO); Intent launchIntent = new Intent(this, PlaybackService.class); @@ -93,6 +82,22 @@ public class VideoplayerActivity extends MediaplayerActivity { } } + @Override + protected void onPause() { + super.onPause(); + videoControlsHider.stop(); + if (controller != null && controller.getStatus() == PlayerStatus.PLAYING) { + controller.pause(); + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + videoControlsHider.stop(); + videoControlsHider = null; + } + @Override protected boolean loadMediaInfo() { if (!super.loadMediaInfo()) { @@ -104,7 +109,6 @@ public class VideoplayerActivity extends MediaplayerActivity { getSupportActionBar().setTitle(media.getFeedTitle()); return true; } - return false; } @@ -133,14 +137,11 @@ public class VideoplayerActivity extends MediaplayerActivity { @Override protected void onAwaitingVideoSurface() { if (videoSurfaceCreated) { - if (BuildConfig.DEBUG) - Log.d(TAG, - "Videosurface already created, setting videosurface now"); + Log.d(TAG, "Videosurface already created, setting videosurface now"); Pair videoSize = controller.getVideoSize(); if (videoSize != null && videoSize.first > 0 && videoSize.second > 0) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Width,height of video: " + videoSize.first + ", " + videoSize.second); + Log.d(TAG, "Width,height of video: " + videoSize.first + ", " + videoSize.second); videoview.setVideoSize(videoSize.first, videoSize.second); } else { Log.e(TAG, "Could not determine video size"); @@ -156,7 +157,6 @@ public class VideoplayerActivity extends MediaplayerActivity { } else { progressIndicator.setVisibility(View.INVISIBLE); } - } @Override @@ -164,38 +164,23 @@ public class VideoplayerActivity extends MediaplayerActivity { progressIndicator.setVisibility(View.INVISIBLE); } - View.OnTouchListener onVideoviewTouched = new View.OnTouchListener() { - - @Override - public boolean onTouch(View v, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (videoControlsToggler != null) { - videoControlsToggler.cancel(true); - } - toggleVideoControlsVisibility(); - if (videoControlsShowing) { - setupVideoControlsToggler(); - } - - return true; - } else { - return false; + View.OnTouchListener onVideoviewTouched = (v, event) -> { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + videoControlsHider.stop(); + toggleVideoControlsVisibility(); + if (videoControlsShowing) { + setupVideoControlsToggler(); } + return true; + } else { + return false; } }; @SuppressLint("NewApi") void setupVideoControlsToggler() { - if (videoControlsToggler != null) { - videoControlsToggler.cancel(true); - } - videoControlsToggler = new VideoControlsHider(); - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { - videoControlsToggler - .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } else { - videoControlsToggler.execute(); - } + videoControlsHider.stop(); + videoControlsHider.start(); } private void toggleVideoControlsVisibility() { @@ -209,46 +194,6 @@ public class VideoplayerActivity extends MediaplayerActivity { videoControlsShowing = !videoControlsShowing; } - /** - * Hides the videocontrols after a certain period of time. - */ - public class VideoControlsHider extends AsyncTask { - @Override - protected void onCancelled() { - videoControlsToggler = null; - } - - @Override - protected void onPostExecute(Void result) { - videoControlsToggler = null; - } - - private static final int WAITING_INTERVALL = 5000; - private static final String TAG = "VideoControlsToggler"; - - @Override - protected void onProgressUpdate(Void... values) { - if (videoControlsShowing) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Hiding video controls"); - getSupportActionBar().hide(); - hideVideoControls(); - videoControlsShowing = false; - } - } - - @Override - protected Void doInBackground(Void... params) { - try { - Thread.sleep(WAITING_INTERVALL); - } catch (InterruptedException e) { - return null; - } - publishProgress(); - return null; - } - - } private final SurfaceHolder.Callback surfaceHolderCallback = new SurfaceHolder.Callback() { @Override @@ -259,15 +204,13 @@ public class VideoplayerActivity extends MediaplayerActivity { @Override public void surfaceCreated(SurfaceHolder holder) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Videoview holder created"); + Log.d(TAG, "Videoview holder created"); videoSurfaceCreated = true; if (controller.getStatus() == PlayerStatus.PLAYING) { if (controller.serviceAvailable()) { controller.setVideoSurface(holder); } else { - Log.e(TAG, - "Could'nt attach surface to mediaplayer - reference to service was null"); + Log.e(TAG, "Could'nt attach surface to mediaplayer - reference to service was null"); } } @@ -275,8 +218,7 @@ public class VideoplayerActivity extends MediaplayerActivity { @Override public void surfaceDestroyed(SurfaceHolder holder) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Videosurface was destroyed"); + Log.d(TAG, "Videosurface was destroyed"); videoSurfaceCreated = false; controller.notifyVideoSurfaceAbandoned(); } @@ -286,9 +228,7 @@ public class VideoplayerActivity extends MediaplayerActivity { @Override protected void onReloadNotification(int notificationCode) { if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO) { - if (BuildConfig.DEBUG) - Log.d(TAG, - "ReloadNotification received, switching to Audioplayer now"); + Log.d(TAG, "ReloadNotification received, switching to Audioplayer now"); finish(); startActivity(new Intent(this, AudioplayerActivity.class)); } @@ -297,9 +237,7 @@ public class VideoplayerActivity extends MediaplayerActivity { @Override public void onStartTrackingTouch(SeekBar seekBar) { super.onStartTrackingTouch(seekBar); - if (videoControlsToggler != null) { - videoControlsToggler.cancel(true); - } + videoControlsHider.stop(); } @Override @@ -356,7 +294,6 @@ public class VideoplayerActivity extends MediaplayerActivity { return R.layout.videoplayer_activity; } - @Override protected void setScreenOn(boolean enable) { super.setScreenOn(enable); @@ -366,4 +303,38 @@ public class VideoplayerActivity extends MediaplayerActivity { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } } + + private static class VideoControlsHider extends Handler { + + private static final int DELAY = 5000; + + private WeakReference activity; + + public VideoControlsHider(VideoplayerActivity activity) { + this.activity = new WeakReference<>(activity); + } + + private final Runnable hideVideoControls = () -> { + VideoplayerActivity vpa = activity.get(); + if(vpa == null) { + return; + } + if (vpa.videoControlsShowing) { + Log.d(TAG, "Hiding video controls"); + vpa.getSupportActionBar().hide(); + vpa.hideVideoControls(); + vpa.videoControlsShowing = false; + } + }; + + public void start() { + this.postDelayed(hideVideoControls, DELAY); + } + + public void stop() { + this.removeCallbacks(hideVideoControls); + } + + } + } diff --git a/app/src/main/res/layout/videoplayer_activity.xml b/app/src/main/res/layout/videoplayer_activity.xml index 766cd6e04..1775a94dc 100644 --- a/app/src/main/res/layout/videoplayer_activity.xml +++ b/app/src/main/res/layout/videoplayer_activity.xml @@ -77,7 +77,9 @@ android:layout_toLeftOf="@+id/txtvLength" android:layout_toRightOf="@+id/txtvPosition" android:max="500" /> + + - \ No newline at end of file + diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java index 1952c068f..31cb25d40 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java @@ -18,7 +18,6 @@ import android.text.TextUtils; import android.util.Log; import android.util.Pair; import android.view.SurfaceHolder; -import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.SeekBar; @@ -78,18 +77,18 @@ public abstract class PlaybackController { this.activity = activity; this.reinitOnPause = reinitOnPause; schedExecutor = new ScheduledThreadPoolExecutor(SCHED_EX_POOLSIZE, - r -> { - Thread t = new Thread(r); - t.setPriority(Thread.MIN_PRIORITY); - return t; - }, new RejectedExecutionHandler() { - @Override - public void rejectedExecution(Runnable r, - ThreadPoolExecutor executor) { - Log.w(TAG, + r -> { + Thread t = new Thread(r); + t.setPriority(Thread.MIN_PRIORITY); + return t; + }, new RejectedExecutionHandler() { + @Override + public void rejectedExecution(Runnable r, + ThreadPoolExecutor executor) { + Log.w(TAG, "Rejected execution of runnable in schedExecutor"); - } } + } ); } @@ -415,7 +414,6 @@ public abstract class PlaybackController { Log.d(TAG, "status: " + status.toString()); switch (status) { - case ERROR: postStatusMsg(R.string.player_error_msg); handleError(MediaPlayer.MEDIA_ERROR_UNKNOWN); @@ -575,37 +573,32 @@ public abstract class PlaybackController { } public OnClickListener newOnPlayButtonClickListener() { - return new OnClickListener() { - @Override - public void onClick(View v) { - if (playbackService != null) { - switch (status) { - case PLAYING: - playbackService.pause(true, reinitOnPause); - break; - case PAUSED: - case PREPARED: - playbackService.resume(); - break; - case PREPARING: - playbackService.setStartWhenPrepared(!playbackService - .isStartWhenPrepared()); - if (reinitOnPause - && playbackService.isStartWhenPrepared() == false) { - playbackService.reinit(); - } - break; - case INITIALIZED: - playbackService.setStartWhenPrepared(true); - playbackService.prepare(); - break; + return v -> { + if (playbackService == null) { + Log.w(TAG, "Play/Pause button was pressed, but playbackservice was null!"); + return; + } + switch (status) { + case PLAYING: + playbackService.pause(true, reinitOnPause); + break; + case PAUSED: + case PREPARED: + playbackService.resume(); + break; + case PREPARING: + playbackService.setStartWhenPrepared(!playbackService + .isStartWhenPrepared()); + if (reinitOnPause + && playbackService.isStartWhenPrepared() == false) { + playbackService.reinit(); } - } else { - Log.w(TAG, - "Play/Pause button was pressed, but playbackservice was null!"); - } + break; + case INITIALIZED: + playbackService.setStartWhenPrepared(true); + playbackService.prepare(); + break; } - }; } -- cgit v1.2.3 From 4f6ba23cbf8d2f2f3c165dce70c2fe8d016ee2eb Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 10 Jan 2016 17:28:23 +0100 Subject: Video Player: Add rewind and fast forward buttons --- .../antennapod/activity/MediaplayerActivity.java | 20 ++++++------ .../antennapod/activity/VideoplayerActivity.java | 16 +++++----- app/src/main/res/layout/videoplayer_activity.xml | 37 +++++++++++++++++++--- 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 396adbd81..a066beee9 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -639,17 +639,19 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O } } checkFavorite(); - if(controller == null) { - butPlaybackSpeed.setVisibility(View.GONE); - } else { - butPlaybackSpeed.setVisibility(View.VISIBLE); - if (controller.canSetPlaybackSpeed()) { - ViewCompat.setAlpha(butPlaybackSpeed, 1.0f); + if(butPlaybackSpeed != null) { + if (controller == null) { + butPlaybackSpeed.setVisibility(View.GONE); } 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; } else { return false; @@ -865,7 +867,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O } private void updateButPlaybackSpeed() { - if (controller != null) { + if (controller != null && butPlaybackSpeed != null) { butPlaybackSpeed.setText(UserPreferences.getPlaybackSpeed() + "x"); } } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index 8d5ca5403..fbea102eb 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -43,6 +43,7 @@ public class VideoplayerActivity extends MediaplayerActivity { private VideoControlsHider videoControlsHider = new VideoControlsHider(this); + private LinearLayout controls; private LinearLayout videoOverlay; private AspectRatioVideoView videoview; private ProgressBar progressIndicator; @@ -116,6 +117,7 @@ public class VideoplayerActivity extends MediaplayerActivity { protected void setupGUI() { super.setupGUI(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); + controls = (LinearLayout) findViewById(R.id.controls); videoOverlay = (LinearLayout) findViewById(R.id.overlay); videoview = (AspectRatioVideoView) findViewById(R.id.videoview); progressIndicator = (ProgressBar) findViewById(R.id.progressIndicator); @@ -259,12 +261,11 @@ public class VideoplayerActivity extends MediaplayerActivity { @SuppressLint("NewApi") private void showVideoControls() { videoOverlay.setVisibility(View.VISIBLE); - butPlay.setVisibility(View.VISIBLE); - final Animation animation = AnimationUtils.loadAnimation(this, - R.anim.fade_in); + controls.setVisibility(View.VISIBLE); + final Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade_in); if (animation != null) { videoOverlay.startAnimation(animation); - butPlay.startAnimation(animation); + controls.startAnimation(animation); } if (Build.VERSION.SDK_INT >= 14) { videoview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); @@ -273,11 +274,10 @@ public class VideoplayerActivity extends MediaplayerActivity { @SuppressLint("NewApi") private void hideVideoControls() { - final Animation animation = AnimationUtils.loadAnimation(this, - R.anim.fade_out); + final Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade_out); if (animation != null) { videoOverlay.startAnimation(animation); - butPlay.startAnimation(animation); + controls.startAnimation(animation); } if (Build.VERSION.SDK_INT >= 14) { 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.setVisibility(View.GONE); - butPlay.setVisibility(View.GONE); + controls.setVisibility(View.GONE); } @Override diff --git a/app/src/main/res/layout/videoplayer_activity.xml b/app/src/main/res/layout/videoplayer_activity.xml index 1775a94dc..2e1097fb8 100644 --- a/app/src/main/res/layout/videoplayer_activity.xml +++ b/app/src/main/res/layout/videoplayer_activity.xml @@ -19,14 +19,41 @@ android:indeterminateOnly="true" android:visibility="invisible" /> - + android:orientation="horizontal"> + + + + + + + +