[Android] [PATCH 1/6] rename PlaybackServiceController to PlaybackServiceClient
Thomas Guillem
thomas at gllm.fr
Thu Jun 11 17:45:39 CEST 2015
---
.../org/videolan/vlc/PlaybackServiceClient.java | 536 +++++++++++++++++++++
.../videolan/vlc/PlaybackServiceController.java | 536 ---------------------
.../vlc/gui/AudioPlayerContainerActivity.java | 10 +-
.../src/org/videolan/vlc/gui/HistoryAdapter.java | 8 +-
.../src/org/videolan/vlc/gui/HistoryFragment.java | 4 +-
.../org/videolan/vlc/gui/PreferencesActivity.java | 13 +-
.../videolan/vlc/gui/audio/AudioAlbumFragment.java | 6 +-
.../vlc/gui/audio/AudioAlbumsSongsFragment.java | 8 +-
.../vlc/gui/audio/AudioBrowserFragment.java | 6 +-
.../org/videolan/vlc/gui/audio/AudioPlayer.java | 6 +-
.../vlc/gui/browser/BaseBrowserFragment.java | 7 +-
.../videolan/vlc/gui/video/VideoGridFragment.java | 10 +-
.../vlc/gui/video/VideoPlayerActivity.java | 12 +-
vlc-android/src/org/videolan/vlc/util/Util.java | 8 +-
.../videolan/vlc/widget/AudioMediaSwitcher.java | 4 +-
.../vlc/gui/tv/MediaItemDetailsFragment.java | 8 +-
.../gui/tv/audioplayer/AudioPlayerActivity.java | 8 +-
17 files changed, 593 insertions(+), 597 deletions(-)
create mode 100644 vlc-android/src/org/videolan/vlc/PlaybackServiceClient.java
delete mode 100644 vlc-android/src/org/videolan/vlc/PlaybackServiceController.java
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackServiceClient.java b/vlc-android/src/org/videolan/vlc/PlaybackServiceClient.java
new file mode 100644
index 0000000..bddb420
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/PlaybackServiceClient.java
@@ -0,0 +1,536 @@
+/*****************************************************************************
+ * PlaybackServiceClient.java
+ *****************************************************************************
+ * Copyright © 2011-2015 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+package org.videolan.vlc;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.graphics.Bitmap;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+import org.videolan.vlc.interfaces.IAudioPlayer;
+import org.videolan.vlc.interfaces.IAudioPlayerControl;
+import org.videolan.vlc.interfaces.IPlaybackService;
+import org.videolan.vlc.interfaces.IPlaybackServiceCallback;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PlaybackServiceClient implements IAudioPlayerControl {
+ public static final String TAG = "PlaybackServiceClient";
+
+ private static PlaybackServiceClient mInstance;
+ private static boolean mIsBound = false;
+ private IPlaybackService mAudioServiceBinder;
+ private ServiceConnection mAudioServiceConnection;
+ private final ArrayList<IAudioPlayer> mAudioPlayer;
+ private final ArrayList<MediaPlayedListener> mMediaPlayedListener;
+
+ public interface MediaPlayedListener {
+ public void onMediaPlayedAdded(MediaWrapper media, int index);
+ public void onMediaPlayedRemoved(int index);
+ }
+
+ private final IPlaybackServiceCallback mCallback = new IPlaybackServiceCallback.Stub() {
+ @Override
+ public void update() throws RemoteException {
+ updateAudioPlayer();
+ }
+
+ @Override
+ public void updateProgress() throws RemoteException {
+ updateProgressAudioPlayer();
+ }
+
+ @Override
+ public void onMediaPlayedAdded(MediaWrapper media, int index) throws RemoteException {
+ updateMediaPlayedAdded(media, index);
+ }
+
+ @Override
+ public void onMediaPlayedRemoved(int index) throws RemoteException {
+ updateMediaPlayedRemoved(index);
+ }
+ };
+
+ private PlaybackServiceClient() {
+ mAudioPlayer = new ArrayList<IAudioPlayer>();
+ mMediaPlayedListener = new ArrayList<MediaPlayedListener>();
+ }
+
+ public static PlaybackServiceClient getInstance() {
+ if (mInstance == null) {
+ mInstance = new PlaybackServiceClient();
+ }
+ return mInstance;
+ }
+
+ /**
+ * The connection listener interface for the audio service
+ */
+ public interface AudioServiceConnectionListener {
+ public void onConnectionSuccess();
+ public void onConnectionFailed();
+ }
+
+ /**
+ * Bind to audio service if it is running
+ */
+ public void bindAudioService(Context context) {
+ bindAudioService(context, null);
+ }
+
+ public void bindAudioService(Context context, final AudioServiceConnectionListener connectionListerner) {
+ if (context == null) {
+ Log.w(TAG, "bindAudioService() with null Context. Ooops" );
+ return;
+ }
+ context = context.getApplicationContext();
+
+ if (!mIsBound) {
+ Intent service = new Intent(context, PlaybackService.class);
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ final boolean enableHS = prefs.getBoolean("enable_headset_detection", true);
+
+ // Setup audio service connection
+ mAudioServiceConnection = new ServiceConnection() {
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ Log.d(TAG, "Service Disconnected");
+ mAudioServiceBinder = null;
+ mIsBound = false;
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ if (!mIsBound) // Can happen if unbind is called quickly before this callback
+ return;
+ Log.d(TAG, "Service Connected");
+ mAudioServiceBinder = IPlaybackService.Stub.asInterface(service);
+
+ // Register controller to the service
+ try {
+ mAudioServiceBinder.addAudioCallback(mCallback);
+ mAudioServiceBinder.detectHeadset(enableHS);
+ if (connectionListerner != null)
+ connectionListerner.onConnectionSuccess();
+ } catch (RemoteException e) {
+ Log.e(TAG, "remote procedure call failed: addAudioCallback()");
+ if (connectionListerner != null)
+ connectionListerner.onConnectionFailed();
+ }
+ updateAudioPlayer();
+ }
+ };
+
+ mIsBound = context.bindService(service, mAudioServiceConnection, Context.BIND_AUTO_CREATE);
+ } else {
+ // Register controller to the service
+ try {
+ if (mAudioServiceBinder != null)
+ mAudioServiceBinder.addAudioCallback(mCallback);
+ if (connectionListerner != null)
+ connectionListerner.onConnectionSuccess();
+ } catch (RemoteException e) {
+ Log.e(TAG, "remote procedure call failed: addAudioCallback()");
+ if (connectionListerner != null)
+ connectionListerner.onConnectionFailed();
+ }
+ }
+ }
+
+ public void unbindAudioService(Context context) {
+ if (context == null) {
+ Log.w(TAG, "unbindAudioService() with null Context. Ooops" );
+ return;
+ }
+ context = context.getApplicationContext();
+
+ if (mIsBound) {
+ mIsBound = false;
+ try {
+ if (mAudioServiceBinder != null)
+ mAudioServiceBinder.removeAudioCallback(mCallback);
+ } catch (RemoteException e) {
+ Log.e(TAG, "remote procedure call failed: removeAudioCallback()");
+ }
+ context.unbindService(mAudioServiceConnection);
+ mAudioServiceBinder = null;
+ mAudioServiceConnection = null;
+ }
+ }
+
+ /**
+ * Add a MediaPlayedListener
+ * @param li
+ */
+ public void addMediaPlayedListener(MediaPlayedListener li) {
+ if (!mMediaPlayedListener.contains(li))
+ mMediaPlayedListener.add(li);
+ }
+
+ /**
+ * Remove MediaPlayedListener from list
+ * @param li
+ */
+ public void removeMediaPlayedListener(MediaPlayedListener li) {
+ if (mMediaPlayedListener.contains(li))
+ mMediaPlayedListener.remove(li);
+ }
+
+ /**
+ * Add a AudioPlayer
+ * @param ap
+ */
+ public void addAudioPlayer(IAudioPlayer ap) {
+ if (!mAudioPlayer.contains(ap))
+ mAudioPlayer.add(ap);
+ }
+
+ /**
+ * Remove AudioPlayer from list
+ * @param ap
+ */
+ public void removeAudioPlayer(IAudioPlayer ap) {
+ if (mAudioPlayer.contains(ap))
+ mAudioPlayer.remove(ap);
+ }
+
+ /**
+ * Update all AudioPlayer
+ */
+ private void updateAudioPlayer() {
+ for (IAudioPlayer player : mAudioPlayer)
+ player.update();
+ }
+
+ /**
+ * Update the progress of all AudioPlayers
+ */
+ private void updateProgressAudioPlayer() {
+ for (IAudioPlayer player : mAudioPlayer)
+ player.updateProgress();
+ }
+
+ private void updateMediaPlayedAdded(MediaWrapper media, int index) {
+ for (MediaPlayedListener listener : mMediaPlayedListener) {
+ listener.onMediaPlayedAdded(media, index);
+ }
+ }
+
+ private void updateMediaPlayedRemoved(int index) {
+ for (MediaPlayedListener listener : mMediaPlayedListener) {
+ listener.onMediaPlayedRemoved(index);
+ }
+ }
+
+ /**
+ * This is a handy utility function to call remote procedure calls from mAudioServiceBinder
+ * to reduce code duplication across methods of AudioServiceController.
+ *
+ * @param instance The instance of IPlaybackService to call, usually mAudioServiceBinder
+ * @param returnType Return type of the method being called
+ * @param defaultValue Default value to return in case of null or exception
+ * @param functionName The function name to call, e.g. "stop"
+ * @param parameterTypes List of parameter types. Pass null if none.
+ * @param parameters List of parameters. Must be in same order as parameterTypes. Pass null if none.
+ * @return The results of the RPC or defaultValue if error
+ */
+ private <T> T remoteProcedureCall(IPlaybackService instance, Class<T> returnType, T defaultValue, String functionName, Class<?> parameterTypes[], Object parameters[]) {
+ if(instance == null) {
+ return defaultValue;
+ }
+
+ try {
+ Method m = IPlaybackService.class.getMethod(functionName, parameterTypes);
+ @SuppressWarnings("unchecked")
+ T returnVal = (T) m.invoke(instance, parameters);
+ return returnVal;
+ } catch(NoSuchMethodException e) {
+ e.printStackTrace();
+ return defaultValue;
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ return defaultValue;
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ return defaultValue;
+ } catch (InvocationTargetException e) {
+ if(e.getTargetException() instanceof RemoteException) {
+ Log.e(TAG, "remote procedure call failed: " + functionName + "()");
+ }
+ return defaultValue;
+ }
+ }
+
+ public void loadLocation(String mediaPath) {
+ ArrayList < String > arrayList = new ArrayList<String>();
+ arrayList.add(mediaPath);
+ loadLocations(arrayList, 0);
+ }
+
+
+ public void load(MediaWrapper media, boolean forceAudio) {
+ ArrayList<MediaWrapper> arrayList = new ArrayList<MediaWrapper>();
+ arrayList.add(media);
+ load(arrayList, 0, forceAudio);
+ }
+
+ public void load(MediaWrapper media) {
+ load(media, false);
+ }
+
+ public void loadLocations(List<String> mediaPathList, int position) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void) null, "loadLocations",
+ new Class<?>[]{List.class, int.class},
+ new Object[]{mediaPathList, position});
+ }
+
+ public void load(List<MediaWrapper> mediaList, int position) {
+ load(mediaList, position, false);
+ }
+
+ public void load(List<MediaWrapper> mediaList, int position, boolean forceAudio) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void) null, "load",
+ new Class<?>[]{List.class, int.class, boolean.class},
+ new Object[]{mediaList, position, forceAudio});
+ }
+
+ public void append(MediaWrapper media) {
+ ArrayList<MediaWrapper> arrayList = new ArrayList<MediaWrapper>();
+ arrayList.add(media);
+ append(arrayList);
+ }
+
+ public void append(List<MediaWrapper> mediaList) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void) null, "append",
+ new Class<?>[]{List.class},
+ new Object[]{mediaList});
+ }
+
+ public void moveItem(int positionStart, int positionEnd) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "moveItem",
+ new Class<?>[] { int.class, int.class },
+ new Object[] { positionStart, positionEnd } );
+ }
+
+ public void remove(int position) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "remove",
+ new Class<?>[] { int.class },
+ new Object[] { position } );
+ }
+
+ public void removeLocation(String location) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "removeLocation",
+ new Class<?>[] { String.class },
+ new Object[] { location } );
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<MediaWrapper> getMedias() {
+ return remoteProcedureCall(mAudioServiceBinder, List.class, null, "getMedias", null, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<String> getMediaLocations() {
+ List<String> def = new ArrayList<String>();
+ return remoteProcedureCall(mAudioServiceBinder, List.class, def, "getMediaLocations", null, null);
+ }
+
+ public String getCurrentMediaLocation() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getCurrentMediaLocation", null, null);
+ }
+
+ public MediaWrapper getCurrentMediaWrapper() {
+ return remoteProcedureCall(mAudioServiceBinder, MediaWrapper.class, (MediaWrapper)null, "getCurrentMediaWrapper", null, null);
+ }
+
+ public void stop() {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "stop", null, null);
+ }
+
+ public void showWithoutParse(int u) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "showWithoutParse",
+ new Class<?>[] { int.class },
+ new Object[] { u } );
+ }
+
+ public void playIndex(int i) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "playIndex",
+ new Class<?>[] { int.class },
+ new Object[] { i } );
+ }
+
+ @Override
+ public String getAlbum() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getAlbum", null, null);
+ }
+
+ @Override
+ public String getArtist() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtist", null, null);
+ }
+
+ @Override
+ public String getArtistPrev() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtistPrev", null, null);
+ }
+
+ @Override
+ public String getArtistNext() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtistNext", null, null);
+ }
+
+ @Override
+ public String getTitle() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitle", null, null);
+ }
+
+ @Override
+ public String getTitlePrev() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitlePrev", null, null);
+ }
+
+ @Override
+ public String getTitleNext() {
+ return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitleNext", null, null);
+ }
+
+ @Override
+ public boolean isPlaying() {
+ return hasMedia() && remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "isPlaying", null, null);
+ }
+
+ @Override
+ public void pause() {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "pause", null, null);
+ }
+
+ @Override
+ public void play() {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "play", null, null);
+ }
+
+ @Override
+ public boolean hasMedia() {
+ return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "hasMedia", null, null);
+ }
+
+ @Override
+ public int getLength() {
+ return remoteProcedureCall(mAudioServiceBinder, int.class, 0, "getLength", null, null);
+ }
+
+ @Override
+ public int getTime() {
+ return remoteProcedureCall(mAudioServiceBinder, int.class, 0, "getTime", null, null);
+ }
+
+ @Override
+ public Bitmap getCover() {
+ return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCover", null, null);
+ }
+
+ @Override
+ public Bitmap getCoverPrev() {
+ return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCoverPrev", null, null);
+ }
+
+ @Override
+ public Bitmap getCoverNext() {
+ return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCoverNext", null, null);
+ }
+
+ @Override
+ public void next() {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "next", null, null);
+ }
+
+ @Override
+ public void previous() {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "previous", null, null);
+ }
+
+ public void setTime(long time) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "setTime",
+ new Class<?>[] { long.class },
+ new Object[] { time } );
+ }
+
+ @Override
+ public boolean hasNext() {
+ return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "hasNext", null, null);
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "hasPrevious", null, null);
+ }
+
+ @Override
+ public void shuffle() {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "shuffle", null, null);
+ }
+
+ @Override
+ public void setRepeatType(PlaybackService.RepeatType t) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "setRepeatType",
+ new Class<?>[] { int.class },
+ new Object[] { t.ordinal() } );
+ }
+
+ @Override
+ public boolean isShuffling() {
+ return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "isShuffling", null, null);
+ }
+
+ @Override
+ public PlaybackService.RepeatType getRepeatType() {
+ return PlaybackService.RepeatType.values()[
+ remoteProcedureCall(mAudioServiceBinder, int.class, PlaybackService.RepeatType.None.ordinal(), "getRepeatType", null, null)
+ ];
+ }
+
+ @Override
+ public void detectHeadset(boolean enable) {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, null, "detectHeadset",
+ new Class<?>[] { boolean.class },
+ new Object[] { enable } );
+ }
+
+ @Override
+ public float getRate() {
+ return remoteProcedureCall(mAudioServiceBinder, Float.class, (float) 1.0, "getRate", null, null);
+ }
+
+ @Override
+ public void handleVout() {
+ remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "handleVout", null, null);
+ }
+}
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackServiceController.java b/vlc-android/src/org/videolan/vlc/PlaybackServiceController.java
deleted file mode 100644
index 9938777..0000000
--- a/vlc-android/src/org/videolan/vlc/PlaybackServiceController.java
+++ /dev/null
@@ -1,536 +0,0 @@
-/*****************************************************************************
- * AudioServiceController.java
- *****************************************************************************
- * Copyright © 2011-2012 VLC authors and VideoLAN
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-package org.videolan.vlc;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.SharedPreferences;
-import android.graphics.Bitmap;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.preference.PreferenceManager;
-import android.util.Log;
-
-import org.videolan.vlc.interfaces.IAudioPlayer;
-import org.videolan.vlc.interfaces.IAudioPlayerControl;
-import org.videolan.vlc.interfaces.IPlaybackService;
-import org.videolan.vlc.interfaces.IPlaybackServiceCallback;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-public class PlaybackServiceController implements IAudioPlayerControl {
- public static final String TAG = "VLC/PlaylistServiceCtrl";
-
- private static PlaybackServiceController mInstance;
- private static boolean mIsBound = false;
- private IPlaybackService mAudioServiceBinder;
- private ServiceConnection mAudioServiceConnection;
- private final ArrayList<IAudioPlayer> mAudioPlayer;
- private final ArrayList<MediaPlayedListener> mMediaPlayedListener;
-
- public interface MediaPlayedListener {
- public void onMediaPlayedAdded(MediaWrapper media, int index);
- public void onMediaPlayedRemoved(int index);
- }
-
- private final IPlaybackServiceCallback mCallback = new IPlaybackServiceCallback.Stub() {
- @Override
- public void update() throws RemoteException {
- updateAudioPlayer();
- }
-
- @Override
- public void updateProgress() throws RemoteException {
- updateProgressAudioPlayer();
- }
-
- @Override
- public void onMediaPlayedAdded(MediaWrapper media, int index) throws RemoteException {
- updateMediaPlayedAdded(media, index);
- }
-
- @Override
- public void onMediaPlayedRemoved(int index) throws RemoteException {
- updateMediaPlayedRemoved(index);
- }
- };
-
- private PlaybackServiceController() {
- mAudioPlayer = new ArrayList<IAudioPlayer>();
- mMediaPlayedListener = new ArrayList<MediaPlayedListener>();
- }
-
- public static PlaybackServiceController getInstance() {
- if (mInstance == null) {
- mInstance = new PlaybackServiceController();
- }
- return mInstance;
- }
-
- /**
- * The connection listener interface for the audio service
- */
- public interface AudioServiceConnectionListener {
- public void onConnectionSuccess();
- public void onConnectionFailed();
- }
-
- /**
- * Bind to audio service if it is running
- */
- public void bindAudioService(Context context) {
- bindAudioService(context, null);
- }
-
- public void bindAudioService(Context context, final AudioServiceConnectionListener connectionListerner) {
- if (context == null) {
- Log.w(TAG, "bindAudioService() with null Context. Ooops" );
- return;
- }
- context = context.getApplicationContext();
-
- if (!mIsBound) {
- Intent service = new Intent(context, PlaybackService.class);
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- final boolean enableHS = prefs.getBoolean("enable_headset_detection", true);
-
- // Setup audio service connection
- mAudioServiceConnection = new ServiceConnection() {
- @Override
- public void onServiceDisconnected(ComponentName name) {
- Log.d(TAG, "Service Disconnected");
- mAudioServiceBinder = null;
- mIsBound = false;
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- if (!mIsBound) // Can happen if unbind is called quickly before this callback
- return;
- Log.d(TAG, "Service Connected");
- mAudioServiceBinder = IPlaybackService.Stub.asInterface(service);
-
- // Register controller to the service
- try {
- mAudioServiceBinder.addAudioCallback(mCallback);
- mAudioServiceBinder.detectHeadset(enableHS);
- if (connectionListerner != null)
- connectionListerner.onConnectionSuccess();
- } catch (RemoteException e) {
- Log.e(TAG, "remote procedure call failed: addAudioCallback()");
- if (connectionListerner != null)
- connectionListerner.onConnectionFailed();
- }
- updateAudioPlayer();
- }
- };
-
- mIsBound = context.bindService(service, mAudioServiceConnection, Context.BIND_AUTO_CREATE);
- } else {
- // Register controller to the service
- try {
- if (mAudioServiceBinder != null)
- mAudioServiceBinder.addAudioCallback(mCallback);
- if (connectionListerner != null)
- connectionListerner.onConnectionSuccess();
- } catch (RemoteException e) {
- Log.e(TAG, "remote procedure call failed: addAudioCallback()");
- if (connectionListerner != null)
- connectionListerner.onConnectionFailed();
- }
- }
- }
-
- public void unbindAudioService(Context context) {
- if (context == null) {
- Log.w(TAG, "unbindAudioService() with null Context. Ooops" );
- return;
- }
- context = context.getApplicationContext();
-
- if (mIsBound) {
- mIsBound = false;
- try {
- if (mAudioServiceBinder != null)
- mAudioServiceBinder.removeAudioCallback(mCallback);
- } catch (RemoteException e) {
- Log.e(TAG, "remote procedure call failed: removeAudioCallback()");
- }
- context.unbindService(mAudioServiceConnection);
- mAudioServiceBinder = null;
- mAudioServiceConnection = null;
- }
- }
-
- /**
- * Add a MediaPlayedListener
- * @param li
- */
- public void addMediaPlayedListener(MediaPlayedListener li) {
- if (!mMediaPlayedListener.contains(li))
- mMediaPlayedListener.add(li);
- }
-
- /**
- * Remove MediaPlayedListener from list
- * @param li
- */
- public void removeMediaPlayedListener(MediaPlayedListener li) {
- if (mMediaPlayedListener.contains(li))
- mMediaPlayedListener.remove(li);
- }
-
- /**
- * Add a AudioPlayer
- * @param ap
- */
- public void addAudioPlayer(IAudioPlayer ap) {
- if (!mAudioPlayer.contains(ap))
- mAudioPlayer.add(ap);
- }
-
- /**
- * Remove AudioPlayer from list
- * @param ap
- */
- public void removeAudioPlayer(IAudioPlayer ap) {
- if (mAudioPlayer.contains(ap))
- mAudioPlayer.remove(ap);
- }
-
- /**
- * Update all AudioPlayer
- */
- private void updateAudioPlayer() {
- for (IAudioPlayer player : mAudioPlayer)
- player.update();
- }
-
- /**
- * Update the progress of all AudioPlayers
- */
- private void updateProgressAudioPlayer() {
- for (IAudioPlayer player : mAudioPlayer)
- player.updateProgress();
- }
-
- private void updateMediaPlayedAdded(MediaWrapper media, int index) {
- for (MediaPlayedListener listener : mMediaPlayedListener) {
- listener.onMediaPlayedAdded(media, index);
- }
- }
-
- private void updateMediaPlayedRemoved(int index) {
- for (MediaPlayedListener listener : mMediaPlayedListener) {
- listener.onMediaPlayedRemoved(index);
- }
- }
-
- /**
- * This is a handy utility function to call remote procedure calls from mAudioServiceBinder
- * to reduce code duplication across methods of AudioServiceController.
- *
- * @param instance The instance of IPlaybackService to call, usually mAudioServiceBinder
- * @param returnType Return type of the method being called
- * @param defaultValue Default value to return in case of null or exception
- * @param functionName The function name to call, e.g. "stop"
- * @param parameterTypes List of parameter types. Pass null if none.
- * @param parameters List of parameters. Must be in same order as parameterTypes. Pass null if none.
- * @return The results of the RPC or defaultValue if error
- */
- private <T> T remoteProcedureCall(IPlaybackService instance, Class<T> returnType, T defaultValue, String functionName, Class<?> parameterTypes[], Object parameters[]) {
- if(instance == null) {
- return defaultValue;
- }
-
- try {
- Method m = IPlaybackService.class.getMethod(functionName, parameterTypes);
- @SuppressWarnings("unchecked")
- T returnVal = (T) m.invoke(instance, parameters);
- return returnVal;
- } catch(NoSuchMethodException e) {
- e.printStackTrace();
- return defaultValue;
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- return defaultValue;
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- return defaultValue;
- } catch (InvocationTargetException e) {
- if(e.getTargetException() instanceof RemoteException) {
- Log.e(TAG, "remote procedure call failed: " + functionName + "()");
- }
- return defaultValue;
- }
- }
-
- public void loadLocation(String mediaPath) {
- ArrayList < String > arrayList = new ArrayList<String>();
- arrayList.add(mediaPath);
- loadLocations(arrayList, 0);
- }
-
-
- public void load(MediaWrapper media, boolean forceAudio) {
- ArrayList<MediaWrapper> arrayList = new ArrayList<MediaWrapper>();
- arrayList.add(media);
- load(arrayList, 0, forceAudio);
- }
-
- public void load(MediaWrapper media) {
- load(media, false);
- }
-
- public void loadLocations(List<String> mediaPathList, int position) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void) null, "loadLocations",
- new Class<?>[]{List.class, int.class},
- new Object[]{mediaPathList, position});
- }
-
- public void load(List<MediaWrapper> mediaList, int position) {
- load(mediaList, position, false);
- }
-
- public void load(List<MediaWrapper> mediaList, int position, boolean forceAudio) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void) null, "load",
- new Class<?>[]{List.class, int.class, boolean.class},
- new Object[]{mediaList, position, forceAudio});
- }
-
- public void append(MediaWrapper media) {
- ArrayList<MediaWrapper> arrayList = new ArrayList<MediaWrapper>();
- arrayList.add(media);
- append(arrayList);
- }
-
- public void append(List<MediaWrapper> mediaList) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void) null, "append",
- new Class<?>[]{List.class},
- new Object[]{mediaList});
- }
-
- public void moveItem(int positionStart, int positionEnd) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "moveItem",
- new Class<?>[] { int.class, int.class },
- new Object[] { positionStart, positionEnd } );
- }
-
- public void remove(int position) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "remove",
- new Class<?>[] { int.class },
- new Object[] { position } );
- }
-
- public void removeLocation(String location) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "removeLocation",
- new Class<?>[] { String.class },
- new Object[] { location } );
- }
-
- @SuppressWarnings("unchecked")
- public List<MediaWrapper> getMedias() {
- return remoteProcedureCall(mAudioServiceBinder, List.class, null, "getMedias", null, null);
- }
-
- @SuppressWarnings("unchecked")
- public List<String> getMediaLocations() {
- List<String> def = new ArrayList<String>();
- return remoteProcedureCall(mAudioServiceBinder, List.class, def, "getMediaLocations", null, null);
- }
-
- public String getCurrentMediaLocation() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getCurrentMediaLocation", null, null);
- }
-
- public MediaWrapper getCurrentMediaWrapper() {
- return remoteProcedureCall(mAudioServiceBinder, MediaWrapper.class, (MediaWrapper)null, "getCurrentMediaWrapper", null, null);
- }
-
- public void stop() {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "stop", null, null);
- }
-
- public void showWithoutParse(int u) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "showWithoutParse",
- new Class<?>[] { int.class },
- new Object[] { u } );
- }
-
- public void playIndex(int i) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "playIndex",
- new Class<?>[] { int.class },
- new Object[] { i } );
- }
-
- @Override
- public String getAlbum() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getAlbum", null, null);
- }
-
- @Override
- public String getArtist() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtist", null, null);
- }
-
- @Override
- public String getArtistPrev() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtistPrev", null, null);
- }
-
- @Override
- public String getArtistNext() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getArtistNext", null, null);
- }
-
- @Override
- public String getTitle() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitle", null, null);
- }
-
- @Override
- public String getTitlePrev() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitlePrev", null, null);
- }
-
- @Override
- public String getTitleNext() {
- return remoteProcedureCall(mAudioServiceBinder, String.class, (String)null, "getTitleNext", null, null);
- }
-
- @Override
- public boolean isPlaying() {
- return hasMedia() && remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "isPlaying", null, null);
- }
-
- @Override
- public void pause() {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "pause", null, null);
- }
-
- @Override
- public void play() {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "play", null, null);
- }
-
- @Override
- public boolean hasMedia() {
- return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "hasMedia", null, null);
- }
-
- @Override
- public int getLength() {
- return remoteProcedureCall(mAudioServiceBinder, int.class, 0, "getLength", null, null);
- }
-
- @Override
- public int getTime() {
- return remoteProcedureCall(mAudioServiceBinder, int.class, 0, "getTime", null, null);
- }
-
- @Override
- public Bitmap getCover() {
- return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCover", null, null);
- }
-
- @Override
- public Bitmap getCoverPrev() {
- return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCoverPrev", null, null);
- }
-
- @Override
- public Bitmap getCoverNext() {
- return remoteProcedureCall(mAudioServiceBinder, Bitmap.class, (Bitmap)null, "getCoverNext", null, null);
- }
-
- @Override
- public void next() {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "next", null, null);
- }
-
- @Override
- public void previous() {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "previous", null, null);
- }
-
- public void setTime(long time) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "setTime",
- new Class<?>[] { long.class },
- new Object[] { time } );
- }
-
- @Override
- public boolean hasNext() {
- return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "hasNext", null, null);
- }
-
- @Override
- public boolean hasPrevious() {
- return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "hasPrevious", null, null);
- }
-
- @Override
- public void shuffle() {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "shuffle", null, null);
- }
-
- @Override
- public void setRepeatType(PlaybackService.RepeatType t) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "setRepeatType",
- new Class<?>[] { int.class },
- new Object[] { t.ordinal() } );
- }
-
- @Override
- public boolean isShuffling() {
- return remoteProcedureCall(mAudioServiceBinder, boolean.class, false, "isShuffling", null, null);
- }
-
- @Override
- public PlaybackService.RepeatType getRepeatType() {
- return PlaybackService.RepeatType.values()[
- remoteProcedureCall(mAudioServiceBinder, int.class, PlaybackService.RepeatType.None.ordinal(), "getRepeatType", null, null)
- ];
- }
-
- @Override
- public void detectHeadset(boolean enable) {
- remoteProcedureCall(mAudioServiceBinder, Void.class, null, "detectHeadset",
- new Class<?>[] { boolean.class },
- new Object[] { enable } );
- }
-
- @Override
- public float getRate() {
- return remoteProcedureCall(mAudioServiceBinder, Float.class, (float) 1.0, "getRate", null, null);
- }
-
- @Override
- public void handleVout() {
- remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "handleVout", null, null);
- }
-}
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index 0555bbc..281f706 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -39,7 +39,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import org.videolan.vlc.BuildConfig;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.audio.AudioPlayer;
import org.videolan.vlc.util.Util;
@@ -53,7 +53,7 @@ public class AudioPlayerContainerActivity extends AppCompatActivity {
protected ActionBar mActionBar;
protected Toolbar mToolbar;
protected AudioPlayer mAudioPlayer;
- protected PlaybackServiceController mAudioController;
+ protected PlaybackServiceClient mAudioController;
protected SlidingPaneLayout mSlidingPane;
protected View mAudioPlayerFilling;
protected SharedPreferences mSettings;
@@ -83,7 +83,7 @@ public class AudioPlayerContainerActivity extends AppCompatActivity {
/* Set up the audio player */
mAudioPlayer = new AudioPlayer();
mAudioPlayer.setUserVisibleHint(false);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
getSupportFragmentManager().beginTransaction()
.replace(R.id.audio_player, mAudioPlayer)
@@ -112,14 +112,14 @@ public class AudioPlayerContainerActivity extends AppCompatActivity {
protected void onResume() {
super.onResume();
mAudioController.addAudioPlayer(mAudioPlayer);
- PlaybackServiceController.getInstance().bindAudioService(this);
+ PlaybackServiceClient.getInstance().bindAudioService(this);
}
@Override
protected void onPause() {
super.onPause();
mAudioController.removeAudioPlayer(mAudioPlayer);
- PlaybackServiceController.getInstance().unbindAudioService(this);
+ PlaybackServiceClient.getInstance().unbindAudioService(this);
}
private void applyTheme() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
index a69e4e0..a118d9b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
@@ -31,7 +31,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.audio.AudioUtil;
@@ -39,17 +39,17 @@ import org.videolan.vlc.util.Util;
import java.util.ArrayList;
-public class HistoryAdapter extends BaseAdapter implements PlaybackServiceController.MediaPlayedListener {
+public class HistoryAdapter extends BaseAdapter implements PlaybackServiceClient.MediaPlayedListener {
public final static String TAG = "VLC/HistoryAdapter";
private LayoutInflater mInflater;
- private final PlaybackServiceController mAudioController;
+ private final PlaybackServiceClient mAudioController;
private final ArrayList<MediaWrapper> mMediaList;
public HistoryAdapter(Context context) {
mInflater = LayoutInflater.from(context);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
mMediaList = new ArrayList<MediaWrapper>();
diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
index 0c66079..ae8bd2e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
@@ -36,7 +36,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView;
import org.videolan.libvlc.util.AndroidUtil;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.browser.MediaBrowserFragment;
import org.videolan.vlc.interfaces.IRefreshable;
@@ -124,7 +124,7 @@ public class HistoryFragment extends MediaBrowserFragment implements IRefreshabl
}
private void playListIndex(int position) {
- PlaybackServiceController audioController = PlaybackServiceController.getInstance();
+ PlaybackServiceClient audioController = PlaybackServiceClient.getInstance();
audioController.playIndex(position);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index 38fedc8..184650c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -50,10 +50,9 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import org.videolan.libvlc.util.HWDecoderUtil;
-import org.videolan.libvlc.LibVLC;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.PlaybackService;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.audio.AudioUtil;
import org.videolan.vlc.util.AndroidDevices;
@@ -125,7 +124,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
- PlaybackServiceController.getInstance().detectHeadset(checkboxHS.isChecked());
+ PlaybackServiceClient.getInstance().detectHeadset(checkboxHS.isChecked());
return true;
}
});
@@ -375,22 +374,22 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
@Override
protected void onResume() {
super.onResume();
- PlaybackServiceController.getInstance().bindAudioService(this);
+ PlaybackServiceClient.getInstance().bindAudioService(this);
}
@Override
protected void onPause() {
super.onPause();
- PlaybackServiceController.getInstance().unbindAudioService(this);
+ PlaybackServiceClient.getInstance().unbindAudioService(this);
}
private void restartService(Context context) {
Intent service = new Intent(context, PlaybackService.class);
- PlaybackServiceController.getInstance().unbindAudioService(PreferencesActivity.this);
+ PlaybackServiceClient.getInstance().unbindAudioService(PreferencesActivity.this);
context.stopService(service);
context.startService(service);
- PlaybackServiceController.getInstance().bindAudioService(PreferencesActivity.this);
+ PlaybackServiceClient.getInstance().bindAudioService(PreferencesActivity.this);
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java
index 2a6e119..d9e50e3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java
@@ -46,7 +46,7 @@ import android.widget.ListView;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.util.AndroidDevices;
@@ -56,7 +56,7 @@ public class AudioAlbumFragment extends Fragment implements AdapterView.OnItemCl
public final static String TAG = "VLC/AudioAlbumFragment";
- PlaybackServiceController mAudioController;
+ PlaybackServiceClient mAudioController;
private AlbumAdapter mAdapter;
private ArrayList<MediaWrapper> mMediaList;
@@ -70,7 +70,7 @@ public class AudioAlbumFragment extends Fragment implements AdapterView.OnItemCl
mAdapter.setContextPopupMenuListener(mContextPopupMenuListener);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
if (savedInstanceState != null)
setMediaList(savedInstanceState.<MediaWrapper>getParcelableArrayList("list"), savedInstanceState.getString("title"));
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 4d87f4e..a54e14c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -52,14 +52,12 @@ import com.android.widget.SlidingTabLayout;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
-import org.videolan.vlc.gui.dialogs.CommonDialogs;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
-import org.videolan.vlc.util.VLCRunnable;
import org.videolan.vlc.util.WeakHandler;
import org.videolan.vlc.widget.SwipeRefreshLayout;
@@ -76,7 +74,7 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
private static final int DELETE_MEDIA = 0;
private static final int DELETE_DURATION = 3000;
- PlaybackServiceController mAudioController;
+ PlaybackServiceClient mAudioController;
private MediaLibrary mMediaLibrary;
private SwipeRefreshLayout mSwipeRefreshLayout;
@@ -108,7 +106,7 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
mAlbumsAdapter.setContextPopupMenuListener(mContextPopupMenuListener);
mSongsAdapter.setContextPopupMenuListener(mContextPopupMenuListener);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
mMediaLibrary = MediaLibrary.getInstance();
if (savedInstanceState != null)
setMediaList(savedInstanceState.<MediaWrapper>getParcelableArrayList("list"), savedInstanceState.getString("title"));
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 632d91d..cfdbe9c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -56,7 +56,7 @@ import org.videolan.libvlc.util.MediaBrowser;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.MainActivity;
@@ -82,7 +82,7 @@ import java.util.concurrent.Executors;
public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeRefreshLayout.OnRefreshListener, SlidingTabLayout.OnTabChangedListener, MediaBrowser.EventListener, IBrowser {
public final static String TAG = "VLC/AudioBrowserFragment";
- private PlaybackServiceController mAudioController;
+ private PlaybackServiceClient mAudioController;
private MediaLibrary mMediaLibrary;
private MediaBrowser mMediaBrowser;
private MainActivity mMainActivity;
@@ -121,7 +121,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
mMediaLibrary = MediaLibrary.getInstance();
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index f13510d..9d8f9bd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -52,7 +52,7 @@ import android.widget.ViewSwitcher;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.PlaybackService;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.AudioPlayerContainerActivity;
@@ -91,7 +91,7 @@ public class AudioPlayer extends Fragment implements IAudioPlayer, View.OnClickL
ViewSwitcher mSwitcher;
- private PlaybackServiceController mAudioController;
+ private PlaybackServiceClient mAudioController;
private boolean mShowRemainingTime = false;
private boolean mPreviewingSeek = false;
@@ -112,7 +112,7 @@ public class AudioPlayer extends Fragment implements IAudioPlayer, View.OnClickL
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
mSongsListAdapter = new AudioPlaylistAdapter(getActivity());
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 76e98a5..350da67 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -46,13 +46,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
-import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.MediaBrowser;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.SecondaryActivity;
@@ -405,7 +404,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
Util.openMedia(getActivity(), (MediaWrapper) mAdapter.getItem(position));
return true;
case R.id.directory_view_append:
- PlaybackServiceController.getInstance().append(mw);
+ PlaybackServiceClient.getInstance().append(mw);
return true;
case R.id.directory_view_delete:
AlertDialog alertDialog = CommonDialogs.deleteMedia(
@@ -425,7 +424,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
startActivity(i);
return true;
case R.id.directory_view_play_audio:
- PlaybackServiceController.getInstance().load(mw);
+ PlaybackServiceClient.getInstance().load(mw);
return true;
case R.id.directory_view_play_video:
VideoPlayerActivity.start(getActivity(), mw.getUri());
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 9291332..50e9284 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -60,7 +60,7 @@ import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaGroup;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.Thumbnailer;
import org.videolan.vlc.VLCApplication;
@@ -113,7 +113,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
private VideoGridAnimator mAnimator;
private MainActivity mMainActivity;
- private PlaybackServiceController mAudioController;
+ private PlaybackServiceClient mAudioController;
// Gridview position saved in onPause()
private int mGVFirstVisiblePos;
@@ -125,7 +125,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
mVideoAdapter = new VideoListAdapter(this);
mMediaLibrary = MediaLibrary.getInstance();
@@ -187,7 +187,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
public void onPause() {
super.onPause();
if (!(getActivity() instanceof MainActivity))
- PlaybackServiceController.getInstance().unbindAudioService(getActivity());
+ PlaybackServiceClient.getInstance().unbindAudioService(getActivity());
mGVFirstVisiblePos = mGridView.getFirstVisiblePosition();
mMediaLibrary.setBrowser(null);
mMediaLibrary.removeUpdateHandler(mHandler);
@@ -201,7 +201,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
public void onResume() {
super.onResume();
if (!(getActivity() instanceof MainActivity))
- PlaybackServiceController.getInstance().bindAudioService(getActivity());
+ PlaybackServiceClient.getInstance().bindAudioService(getActivity());
else
mMainActivity = (MainActivity) getActivity();
mMediaLibrary.setBrowser(this);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 75e0a8f..d1bcdda 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -106,7 +106,7 @@ import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.MediaWrapperListPlayer;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.dialogs.CommonDialogs;
@@ -656,8 +656,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
if (mBound)
return;
mBound = true;
- PlaybackServiceController.getInstance().bindAudioService(this,
- new PlaybackServiceController.AudioServiceConnectionListener() {
+ PlaybackServiceClient.getInstance().bindAudioService(this,
+ new PlaybackServiceClient.AudioServiceConnectionListener() {
@Override
public void onConnectionSuccess() {
mAudioServiceReady = true;
@@ -673,7 +673,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
});
}
private void unbindAudioService() {
- PlaybackServiceController.getInstance().unbindAudioService(this);
+ PlaybackServiceClient.getInstance().unbindAudioService(this);
mAudioServiceReady = false;
mBound = false;
}
@@ -750,7 +750,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
if(mSwitchingView) {
Log.d(TAG, "mLocation = \"" + mUri + "\"");
- PlaybackServiceController.getInstance().showWithoutParse(savedIndexPosition);
+ PlaybackServiceClient.getInstance().showWithoutParse(savedIndexPosition);
unbindAudioService();
return;
}
@@ -2799,7 +2799,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
savedIndexPosition = openedPosition;
} else {
/* prepare playback */
- PlaybackServiceController.getInstance().stop(); // Stop the previous playback.
+ PlaybackServiceClient.getInstance().stop(); // Stop the previous playback.
if (savedIndexPosition == -1 && mUri != null) {
mMediaListPlayer.getMediaList().clear();
final Media media = new Media(LibVLC(), mUri);
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 5699eb9..055aff6 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -43,7 +43,7 @@ import org.videolan.libvlc.Media;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.VLCCallbackTask;
@@ -216,7 +216,7 @@ public class Util {
VLCCallbackTask task = new VLCCallbackTask(context) {
@Override
public void run() {
- PlaybackServiceController c = PlaybackServiceController.getInstance();
+ PlaybackServiceClient c = PlaybackServiceClient.getInstance();
c.load(media);
}
};
@@ -228,7 +228,7 @@ public class Util {
VLCCallbackTask task = new VLCCallbackTask(context){
@Override
public void run() {
- PlaybackServiceController c = PlaybackServiceController.getInstance();
+ PlaybackServiceClient c = PlaybackServiceClient.getInstance();
/* Use the audio player by default. If a video track is
* detected, then it will automatically switch to the video
@@ -246,7 +246,7 @@ public class Util {
VLCCallbackTask task = new VLCCallbackTask(context){
@Override
public void run() {
- PlaybackServiceController c = PlaybackServiceController.getInstance();
+ PlaybackServiceClient c = PlaybackServiceClient.getInstance();
/* Use the audio player by default. If a video track is
* detected, then it will automatically switch to the video
diff --git a/vlc-android/src/org/videolan/vlc/widget/AudioMediaSwitcher.java b/vlc-android/src/org/videolan/vlc/widget/AudioMediaSwitcher.java
index 060bb1b..0afd6ff 100644
--- a/vlc-android/src/org/videolan/vlc/widget/AudioMediaSwitcher.java
+++ b/vlc-android/src/org/videolan/vlc/widget/AudioMediaSwitcher.java
@@ -20,7 +20,7 @@
package org.videolan.vlc.widget;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import android.content.Context;
import android.graphics.Bitmap;
@@ -42,7 +42,7 @@ public abstract class AudioMediaSwitcher extends FlingViewGroup {
}
public void updateMedia() {
- PlaybackServiceController audioController = PlaybackServiceController.getInstance();
+ PlaybackServiceClient audioController = PlaybackServiceClient.getInstance();
if (audioController == null)
return;
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
index 8efd250..718bcc0 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MediaItemDetailsFragment.java
@@ -26,7 +26,7 @@ import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.audio.AudioUtil;
import org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity;
@@ -46,7 +46,7 @@ import android.support.v17.leanback.widget.ListRowPresenter;
import android.support.v17.leanback.widget.OnActionClickedListener;
import android.widget.Toast;
-public class MediaItemDetailsFragment extends DetailsFragment implements PlaybackServiceController.AudioServiceConnectionListener {
+public class MediaItemDetailsFragment extends DetailsFragment implements PlaybackServiceClient.AudioServiceConnectionListener {
private static final String TAG = "MediaItemDetailsFragment";
private static final int ID_PLAY = 1;
private static final int ID_LISTEN = 2;
@@ -54,7 +54,7 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
private static final int ID_FAVORITE_DELETE = 4;
private static final int ID_BROWSE = 5;
private ArrayObjectAdapter mRowsAdapter;
- private PlaybackServiceController mAudioController;
+ private PlaybackServiceClient mAudioController;
private MediaItemDetails mMedia;
private MediaWrapper mMediaWrapper;
private MediaDatabase mDb;
@@ -63,7 +63,7 @@ public class MediaItemDetailsFragment extends DetailsFragment implements Playbac
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
buildDetails();
}
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
index 0614a11..1a6164a 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
@@ -26,7 +26,7 @@ import java.util.Collections;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.PlaybackService;
-import org.videolan.vlc.PlaybackServiceController;
+import org.videolan.vlc.PlaybackServiceClient;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.DividerItemDecoration;
import org.videolan.vlc.gui.audio.AudioUtil;
@@ -47,12 +47,12 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
-public class AudioPlayerActivity extends Activity implements PlaybackServiceController.AudioServiceConnectionListener, IAudioPlayer, View.OnFocusChangeListener {
+public class AudioPlayerActivity extends Activity implements PlaybackServiceClient.AudioServiceConnectionListener, IAudioPlayer, View.OnFocusChangeListener {
public static final String TAG = "VLC/AudioPlayerActivity";
public static final String MEDIA_LIST = "media_list";
- private PlaybackServiceController mAudioController;
+ private PlaybackServiceClient mAudioController;
private RecyclerView mRecyclerView;
private PlaylistAdapter mAdapter;
private LinearLayoutManager mLayoutManager;
@@ -84,7 +84,7 @@ public class AudioPlayerActivity extends Activity implements PlaybackServiceCont
mAdapter = new PlaylistAdapter(this, mMediaList);
mRecyclerView.setAdapter(mAdapter);
- mAudioController = PlaybackServiceController.getInstance();
+ mAudioController = PlaybackServiceClient.getInstance();
mAudioController.getRepeatType();
mTitleTv = (TextView)findViewById(R.id.media_title);
--
2.1.4
More information about the Android
mailing list