diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-03-29 11:09:47 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-03-29 11:09:47 +0100 |
commit | ae849077c78770f096f40e9360250b9e32d14f40 (patch) | |
tree | cbc030c6c942d9ad42d633415a1cb0e1d79b5196 /src/de/danoeh/antennapod/util/playback | |
parent | b5a3c72ac8cfa5b5c5f2af4321f851b5bb293d35 (diff) | |
parent | b2de7512f4c871e882760bfe8bffa27d10c1c68a (diff) | |
download | AntennaPod-ae849077c78770f096f40e9360250b9e32d14f40.zip |
Merge branch 'develop'0.9.8.3
Diffstat (limited to 'src/de/danoeh/antennapod/util/playback')
5 files changed, 42 insertions, 31 deletions
diff --git a/src/de/danoeh/antennapod/util/playback/AudioPlayer.java b/src/de/danoeh/antennapod/util/playback/AudioPlayer.java index 0945303e4..bd49b0d18 100644 --- a/src/de/danoeh/antennapod/util/playback/AudioPlayer.java +++ b/src/de/danoeh/antennapod/util/playback/AudioPlayer.java @@ -3,7 +3,6 @@ package de.danoeh.antennapod.util.playback; import android.content.Context; import android.util.Log; import android.view.SurfaceHolder; - import com.aocate.media.MediaPlayer; public class AudioPlayer extends MediaPlayer implements IPlayer { diff --git a/src/de/danoeh/antennapod/util/playback/ExternalMedia.java b/src/de/danoeh/antennapod/util/playback/ExternalMedia.java index e937ee437..390498cea 100644 --- a/src/de/danoeh/antennapod/util/playback/ExternalMedia.java +++ b/src/de/danoeh/antennapod/util/playback/ExternalMedia.java @@ -1,9 +1,5 @@ package de.danoeh.antennapod.util.playback; -import java.io.InputStream; -import java.util.List; -import java.util.concurrent.Callable; - import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.media.MediaMetadataRetriever; @@ -13,6 +9,10 @@ import de.danoeh.antennapod.feed.Chapter; import de.danoeh.antennapod.feed.MediaType; import de.danoeh.antennapod.util.ChapterUtils; +import java.io.InputStream; +import java.util.List; +import java.util.concurrent.Callable; + /** Represents a media file that is stored on the local storage device. */ public class ExternalMedia implements Playable { diff --git a/src/de/danoeh/antennapod/util/playback/IPlayer.java b/src/de/danoeh/antennapod/util/playback/IPlayer.java index 8c1cf4ef4..99f53fb52 100644 --- a/src/de/danoeh/antennapod/util/playback/IPlayer.java +++ b/src/de/danoeh/antennapod/util/playback/IPlayer.java @@ -1,9 +1,9 @@ package de.danoeh.antennapod.util.playback; -import java.io.IOException; - import android.view.SurfaceHolder; +import java.io.IOException; + public interface IPlayer { boolean canSetPitch(); diff --git a/src/de/danoeh/antennapod/util/playback/Playable.java b/src/de/danoeh/antennapod/util/playback/Playable.java index 98d5fbb36..8eefb0be5 100644 --- a/src/de/danoeh/antennapod/util/playback/Playable.java +++ b/src/de/danoeh/antennapod/util/playback/Playable.java @@ -1,15 +1,6 @@ package de.danoeh.antennapod.util.playback; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.List; -import java.util.concurrent.FutureTask; - import android.content.Context; -import de.danoeh.antennapod.storage.DBReader; -import de.danoeh.antennapod.util.ShownotesProvider; -import org.apache.commons.io.IOUtils; - import android.content.SharedPreferences; import android.media.MediaMetadataRetriever; import android.os.Parcelable; @@ -18,6 +9,13 @@ import de.danoeh.antennapod.asynctask.ImageLoader; import de.danoeh.antennapod.feed.Chapter; import de.danoeh.antennapod.feed.FeedMedia; import de.danoeh.antennapod.feed.MediaType; +import de.danoeh.antennapod.storage.DBReader; +import de.danoeh.antennapod.util.ShownotesProvider; +import org.apache.commons.io.IOUtils; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.List; /** * Interface for objects that can be played by the PlaybackService. diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java index 0781800aa..1992fce2c 100644 --- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java @@ -15,7 +15,7 @@ import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; -import de.danoeh.antennapod.AppConfig; +import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.feed.Chapter; import de.danoeh.antennapod.feed.FeedMedia; @@ -114,7 +114,7 @@ public abstract class PlaybackController { * example in the activity's onStop() method. */ public void release() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Releasing PlaybackController"); try { @@ -160,7 +160,7 @@ public abstract class PlaybackController { * as the arguments of the launch intent. */ private void bindToService() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Trying to connect to service"); AsyncTask<Void, Void, Intent> intentLoader = new AsyncTask<Void, Void, Intent>() { @Override @@ -173,7 +173,7 @@ public abstract class PlaybackController { boolean bound = false; if (!PlaybackService.started) { if (serviceIntent != null) { - if (AppConfig.DEBUG) Log.d(TAG, "Calling start service"); + if (BuildConfig.DEBUG) Log.d(TAG, "Calling start service"); activity.startService(serviceIntent); bound = activity.bindService(serviceIntent, mConnection, 0); } else { @@ -182,13 +182,13 @@ public abstract class PlaybackController { handleStatus(); } } else { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "PlaybackService is running, trying to connect without start command."); bound = activity.bindService(new Intent(activity, PlaybackService.class), mConnection, 0); } - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Result for service binding: " + bound); } }; @@ -200,7 +200,7 @@ public abstract class PlaybackController { * played media or null if no last played media could be found. */ private Intent getPlayLastPlayedMediaIntent() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Trying to restore last played media"); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(activity.getApplicationContext()); @@ -229,7 +229,7 @@ public abstract class PlaybackController { return serviceIntent; } } - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "No last played media found"); return null; } @@ -242,7 +242,7 @@ public abstract class PlaybackController { || (positionObserverFuture != null && positionObserverFuture .isDone()) || positionObserverFuture == null) { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Setting up position observer"); positionObserver = new MediaPositionObserver(); positionObserverFuture = schedExecutor.scheduleWithFixedDelay( @@ -255,7 +255,7 @@ public abstract class PlaybackController { private void cancelPositionObserver() { if (positionObserverFuture != null) { boolean result = positionObserverFuture.cancel(true); - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "PositionObserver cancelled. Result: " + result); } } @@ -268,7 +268,7 @@ public abstract class PlaybackController { .getService(); if (!released) { queryService(); - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Connection to Service established"); } else { Log.i(TAG, "Connection to playback service has been established, but controller has already been released"); @@ -278,7 +278,7 @@ public abstract class PlaybackController { @Override public void onServiceDisconnected(ComponentName name) { playbackService = null; - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Disconnected from Service"); } @@ -287,7 +287,7 @@ public abstract class PlaybackController { protected BroadcastReceiver statusUpdate = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Received statusUpdate Intent."); if (isConnectedToPlaybackService()) { PlaybackServiceMediaPlayer.PSMPInfo info = playbackService.getPSMPInfo(); @@ -345,7 +345,7 @@ public abstract class PlaybackController { } } else { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Bad arguments. Won't handle intent"); } } else { @@ -422,12 +422,16 @@ public abstract class PlaybackController { checkMediaInfoLoaded(); cancelPositionObserver(); updatePlayButtonAppearance(playResource, playText); + if (PlaybackService.getCurrentMediaType() == MediaType.VIDEO) { + setScreenOn(false); + } break; case PLAYING: clearStatusMsg(); checkMediaInfoLoaded(); if (PlaybackService.getCurrentMediaType() == MediaType.VIDEO) { onAwaitingVideoSurface(); + setScreenOn(true); } setupPositionObserver(); updatePlayButtonAppearance(pauseResource, pauseText); @@ -487,7 +491,7 @@ public abstract class PlaybackController { * information has to be refreshed */ void queryService() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Querying service info"); if (playbackService != null) { status = playbackService.getStatus(); @@ -551,6 +555,16 @@ public abstract class PlaybackController { } } + /** + * Should be implemented by classes that show a video. The default implementation + * does nothing + * + * @param enable True if the screen should be kept on, false otherwise + */ + protected void setScreenOn(boolean enable) { + + } + public OnClickListener newOnPlayButtonClickListener() { return new OnClickListener() { @Override |