diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-12-29 22:13:18 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-12-29 22:13:18 +0100 |
commit | 85800d14ac3ab27881ee89ca15bcab2edfb9e0e1 (patch) | |
tree | 99cced6d65963fe7c4a68b8fb57d45c7fcc0d4a7 | |
parent | b8649277098347cf919c366fafc5ebd6c0f77f28 (diff) | |
download | AntennaPod-85800d14ac3ab27881ee89ca15bcab2edfb9e0e1.zip |
Updated video player UI
18 files changed, 134 insertions, 89 deletions
diff --git a/res/drawable-hdpi/ic_action_pause_over_video.png b/res/drawable-hdpi/ic_action_pause_over_video.png Binary files differnew file mode 100755 index 000000000..64b07728f --- /dev/null +++ b/res/drawable-hdpi/ic_action_pause_over_video.png diff --git a/res/drawable-hdpi/ic_action_play_over_video.png b/res/drawable-hdpi/ic_action_play_over_video.png Binary files differnew file mode 100755 index 000000000..a364ca7c2 --- /dev/null +++ b/res/drawable-hdpi/ic_action_play_over_video.png diff --git a/res/drawable-mdpi/ic_action_pause_over_video.png b/res/drawable-mdpi/ic_action_pause_over_video.png Binary files differnew file mode 100755 index 000000000..f478ac321 --- /dev/null +++ b/res/drawable-mdpi/ic_action_pause_over_video.png diff --git a/res/drawable-mdpi/ic_action_play_over_video.png b/res/drawable-mdpi/ic_action_play_over_video.png Binary files differnew file mode 100755 index 000000000..835ff3636 --- /dev/null +++ b/res/drawable-mdpi/ic_action_play_over_video.png diff --git a/res/drawable-xhdpi/ic_action_pause_over_video.png b/res/drawable-xhdpi/ic_action_pause_over_video.png Binary files differnew file mode 100755 index 000000000..b0777a023 --- /dev/null +++ b/res/drawable-xhdpi/ic_action_pause_over_video.png diff --git a/res/drawable-xhdpi/ic_action_play_over_video.png b/res/drawable-xhdpi/ic_action_play_over_video.png Binary files differnew file mode 100755 index 000000000..24331a48c --- /dev/null +++ b/res/drawable-xhdpi/ic_action_play_over_video.png diff --git a/res/drawable-xxhdpi/ic_action_pause_over_video.png b/res/drawable-xxhdpi/ic_action_pause_over_video.png Binary files differnew file mode 100755 index 000000000..fa85601cf --- /dev/null +++ b/res/drawable-xxhdpi/ic_action_pause_over_video.png diff --git a/res/drawable-xxhdpi/ic_action_play_over_video.png b/res/drawable-xxhdpi/ic_action_play_over_video.png Binary files differnew file mode 100755 index 000000000..121be211e --- /dev/null +++ b/res/drawable-xxhdpi/ic_action_play_over_video.png diff --git a/res/drawable/overlay_button_circle_background.xml b/res/drawable/overlay_button_circle_background.xml new file mode 100644 index 000000000..90c51472c --- /dev/null +++ b/res/drawable/overlay_button_circle_background.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> + +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <gradient + android:type="radial" + android:gradientRadius="60" + android:startColor="#000000" + android:endColor="@android:color/transparent"/> +</shape>
\ No newline at end of file diff --git a/res/layout-land/videoplayer_activity.xml b/res/layout-land/videoplayer_activity.xml index 675d9709d..344e86ddd 100644 --- a/res/layout-land/videoplayer_activity.xml +++ b/res/layout-land/videoplayer_activity.xml @@ -6,8 +6,8 @@ <VideoView android:id="@+id/videoview" - android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> <ProgressBar android:id="@+id/progressIndicator" @@ -16,56 +16,29 @@ android:layout_gravity="center" android:visibility="invisible" android:indeterminateOnly="true" /> - <!-- Mediaplayer controls --> + + <ImageButton + android:id="@+id/butPlay" + android:layout_width="80dp" + android:layout_height="80dp" + android:layout_gravity="center" + android:scaleType="fitXY" + android:background="@drawable/overlay_button_circle_background" + android:src="@drawable/ic_action_pause_over_video" /> <LinearLayout android:id="@+id/overlay" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center" - android:background="?attr/overlay_background" + android:background="#80000000" android:orientation="vertical" > <RelativeLayout - android:id="@+id/playercontrol" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_gravity="clip_horizontal" - android:layout_margin="4dp" > - - <ImageButton - android:id="@+id/butPlay" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerHorizontal="true" - android:background="?attr/borderless_button" - android:src="?attr/av_pause" /> - - <ImageButton - android:id="@+id/butFF" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_marginLeft="8dp" - android:layout_toRightOf="@+id/butPlay" - android:background="?attr/borderless_button" - android:src="?attr/av_fast_forward" /> - - <ImageButton - android:id="@+id/butRev" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_marginRight="8dp" - android:layout_toLeftOf="@+id/butPlay" - android:background="?attr/borderless_button" - android:src="?attr/av_rewind" /> - </RelativeLayout> - - <RelativeLayout android:id="@+id/timecontrol" android:layout_width="match_parent" - android:layout_height="30dp" + android:layout_height="50dp" + android:paddingTop="8dp" android:layout_marginBottom="4dp" > <TextView @@ -77,6 +50,9 @@ android:layout_marginBottom="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" + android:layout_marginTop="4dp" + android:textColor="@color/white" + android:textStyle="bold" android:text="@string/position_default_label" /> <TextView @@ -88,6 +64,9 @@ android:layout_marginBottom="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" + android:layout_marginTop="4dp" + android:textColor="@color/white" + android:textStyle="bold" android:text="@string/position_default_label" /> <SeekBar diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index 201cccba3..60589bdf5 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -146,9 +146,13 @@ public abstract class MediaplayerActivity extends ActionBarActivity supportInvalidateOptionsMenu(); } + protected void chooseTheme() { + setTheme(UserPreferences.getTheme()); + } + @Override protected void onCreate(Bundle savedInstanceState) { - setTheme(UserPreferences.getTheme()); + chooseTheme(); super.onCreate(savedInstanceState); if (AppConfig.DEBUG) Log.d(TAG, "Creating Activity"); @@ -419,9 +423,12 @@ public abstract class MediaplayerActivity extends ActionBarActivity butPlay.setOnClickListener(controller.newOnPlayButtonClickListener()); - butFF.setOnClickListener(controller.newOnFFButtonClickListener()); - - butRev.setOnClickListener(controller.newOnRevButtonClickListener()); + if (butFF != null) { + butFF.setOnClickListener(controller.newOnFFButtonClickListener()); + } + if (butRev != null) { + butRev.setOnClickListener(controller.newOnRevButtonClickListener()); + } } diff --git a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java index 19b7cbc04..c980c14cd 100644 --- a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -2,10 +2,13 @@ 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.util.Log; import android.view.*; +import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -21,7 +24,7 @@ import de.danoeh.antennapod.util.playback.ExternalMedia; import de.danoeh.antennapod.util.playback.Playable; /** - * Activity for playing audio files. + * Activity for playing video files. */ public class VideoplayerActivity extends MediaplayerActivity { private static final String TAG = "VideoplayerActivity"; @@ -38,11 +41,17 @@ public class VideoplayerActivity extends MediaplayerActivity { private ProgressBar progressIndicator; @Override - protected void onCreate(Bundle savedInstanceState) { - requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); - setTheme(UserPreferences.getTheme()); + protected void chooseTheme() { + setTheme(R.style.Theme_AntennaPod_Dark); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + if (Build.VERSION.SDK_INT >= 11) { + requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); + } super.onCreate(savedInstanceState); + getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0x80000000)); } @Override @@ -284,14 +293,30 @@ public class VideoplayerActivity extends MediaplayerActivity { private void showVideoControls() { videoOverlay.setVisibility(View.VISIBLE); - videoOverlay.startAnimation(AnimationUtils.loadAnimation(this, - R.anim.fade_in)); + butPlay.setVisibility(View.VISIBLE); + final Animation animation = AnimationUtils.loadAnimation(this, + R.anim.fade_in); + if (animation != null) { + videoOverlay.startAnimation(animation); + butPlay.startAnimation(animation); + } + if (Build.VERSION.SDK_INT >= 14) { + videoview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); + } } private void hideVideoControls() { - videoOverlay.startAnimation(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); + } + if (Build.VERSION.SDK_INT >= 14) { + videoview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); + } videoOverlay.setVisibility(View.GONE); + butPlay.setVisibility(View.GONE); } @Override diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackService.java b/src/de/danoeh/antennapod/service/playback/PlaybackService.java index 9ab1d1291..2b8a04a84 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackService.java @@ -25,7 +25,10 @@ import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.AudioplayerActivity; import de.danoeh.antennapod.activity.VideoplayerActivity; -import de.danoeh.antennapod.feed.*; +import de.danoeh.antennapod.feed.Chapter; +import de.danoeh.antennapod.feed.FeedItem; +import de.danoeh.antennapod.feed.FeedMedia; +import de.danoeh.antennapod.feed.MediaType; import de.danoeh.antennapod.preferences.PlaybackPreferences; import de.danoeh.antennapod.preferences.UserPreferences; import de.danoeh.antennapod.receiver.MediaButtonReceiver; @@ -240,6 +243,11 @@ public class PlaybackService extends Service { stopSelf(); } + if ((flags & Service.START_FLAG_REDELIVERY) != 0) { + if (AppConfig.DEBUG) Log.d(TAG, "onStartCommand is a redelivered intent, calling stopForeground now."); + stopForeground(true); + } + if (keycode != -1) { if (AppConfig.DEBUG) Log.d(TAG, "Received media button event"); @@ -253,7 +261,7 @@ public class PlaybackService extends Service { mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately); } - return Service.START_NOT_STICKY; + return Service.START_REDELIVER_INTENT; } /** diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java index 1c92bd6e6..8ffd55be6 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.service.playback; import android.content.ComponentName; import android.content.Context; import android.media.AudioManager; +import android.media.MediaPlayer; import android.media.RemoteControlClient; import android.os.Handler; import android.os.Message; @@ -113,6 +114,7 @@ public class PlaybackServiceMediaPlayer { public void playMediaObject(final Playable playable, final boolean stream, final boolean startWhenPrepared, final boolean prepareImmediately) { if (playable == null) throw new IllegalArgumentException("playable = null"); + if (AppConfig.DEBUG) Log.d(TAG, "Play media object."); executor.submit(new Runnable() { @Override public void run() { @@ -165,6 +167,11 @@ public class PlaybackServiceMediaPlayer { } setPlayerStatus(PlayerStatus.INITIALIZED, media); + if (mediaType == MediaType.VIDEO) { + VideoPlayer vp = (VideoPlayer) mediaPlayer; + // vp.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT); + } + if (prepareImmediately) { setPlayerStatus(PlayerStatus.PREPARING, media); mediaPlayer.prepare(); diff --git a/src/de/danoeh/antennapod/util/playback/AudioPlayer.java b/src/de/danoeh/antennapod/util/playback/AudioPlayer.java index 68d31324d..0945303e4 100644 --- a/src/de/danoeh/antennapod/util/playback/AudioPlayer.java +++ b/src/de/danoeh/antennapod/util/playback/AudioPlayer.java @@ -27,4 +27,9 @@ public class AudioPlayer extends MediaPlayer implements IPlayer { throw new UnsupportedOperationException("Setting display not supported in Audio Player"); } } + + @Override + public void setVideoScalingMode(int mode) { + throw new UnsupportedOperationException("Setting scaling mode is not supported in Audio Player"); + } } diff --git a/src/de/danoeh/antennapod/util/playback/IPlayer.java b/src/de/danoeh/antennapod/util/playback/IPlayer.java index ca9b36358..8c1cf4ef4 100644 --- a/src/de/danoeh/antennapod/util/playback/IPlayer.java +++ b/src/de/danoeh/antennapod/util/playback/IPlayer.java @@ -61,4 +61,6 @@ public interface IPlayer { void start(); void stop(); + + public void setVideoScalingMode(int mode); } diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java index 07597c422..0d1e62909 100644 --- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java @@ -1,20 +1,7 @@ package de.danoeh.antennapod.util.playback; -import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - import android.app.Activity; -import android.content.BroadcastReceiver; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.ServiceConnection; -import android.content.SharedPreferences; +import android.content.*; import android.content.res.TypedArray; import android.os.AsyncTask; import android.os.IBinder; @@ -39,6 +26,8 @@ import de.danoeh.antennapod.storage.DBTasks; import de.danoeh.antennapod.util.Converter; import de.danoeh.antennapod.util.playback.Playable.PlayableUtils; +import java.util.concurrent.*; + /** * Communicates with the playback service. GUI classes should use this class to * control playback instead of communicating with the PlaybackService directly. @@ -46,8 +35,8 @@ import de.danoeh.antennapod.util.playback.Playable.PlayableUtils; public abstract class PlaybackController { private static final String TAG = "PlaybackController"; - public static final int DEFAULT_SEEK_DELTA = 30000; - public static final int INVALID_TIME = -1; + public static final int DEFAULT_SEEK_DELTA = 30000; + public static final int INVALID_TIME = -1; private final Activity activity; @@ -185,6 +174,7 @@ public abstract class PlaybackController { boolean bound = false; if (!PlaybackService.isRunning) { if (serviceIntent != null) { + if (AppConfig.DEBUG) Log.d(TAG, "Calling start service"); activity.startService(serviceIntent); bound = activity.bindService(serviceIntent, mConnection, 0); } else { @@ -407,11 +397,18 @@ public abstract class PlaybackController { * should be used to update the GUI or start/cancel background threads. */ private void handleStatus() { - TypedArray res = activity.obtainStyledAttributes(new int[]{ - R.attr.av_play, R.attr.av_pause}); - final int playResource = res.getResourceId(0, R.drawable.av_play); - final int pauseResource = res.getResourceId(1, R.drawable.av_pause); - res.recycle(); + final int playResource; + final int pauseResource; + if (PlaybackService.getCurrentMediaType() == MediaType.AUDIO) { + TypedArray res = activity.obtainStyledAttributes(new int[]{ + R.attr.av_play, R.attr.av_pause}); + playResource = res.getResourceId(0, R.drawable.av_play); + pauseResource = res.getResourceId(1, R.drawable.av_pause); + res.recycle(); + } else { + playResource = R.drawable.ic_action_play_over_video; + pauseResource = R.drawable.ic_action_pause_over_video; + } switch (status) { @@ -680,19 +677,19 @@ public abstract class PlaybackController { return playbackService != null && playbackService.canSetSpeed(); } - public void setPlaybackSpeed(float speed) { - if (playbackService != null) { - playbackService.setSpeed(speed); - } - } - - public float getCurrentPlaybackSpeedMultiplier() { - if (canSetPlaybackSpeed()) { - return playbackService.getCurrentPlaybackSpeed(); - } else { - return -1; - } - } + public void setPlaybackSpeed(float speed) { + if (playbackService != null) { + playbackService.setSpeed(speed); + } + } + + public float getCurrentPlaybackSpeedMultiplier() { + if (canSetPlaybackSpeed()) { + return playbackService.getCurrentPlaybackSpeed(); + } else { + return -1; + } + } public boolean isPlayingVideo() { if (playbackService != null) { diff --git a/src/de/danoeh/antennapod/util/playback/VideoPlayer.java b/src/de/danoeh/antennapod/util/playback/VideoPlayer.java index f0a50542c..ea9c692ab 100644 --- a/src/de/danoeh/antennapod/util/playback/VideoPlayer.java +++ b/src/de/danoeh/antennapod/util/playback/VideoPlayer.java @@ -59,4 +59,9 @@ public class VideoPlayer extends MediaPlayer implements IPlayer { Log.e(TAG, "Setting playback speed unsupported in video player"); throw new UnsupportedOperationException("Setting playback speed unsupported in video player"); } + + @Override + public void setVideoScalingMode(int mode) { + super.setVideoScalingMode(mode); + } } |