[Android] AudioService: fix "play as audio"
Thomas Guillem
git at videolan.org
Thu May 7 15:44:12 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu May 7 15:43:15 2015 +0200| [0adfe5c619385c0dbaf229eb21d98d7ca753b1c6] | committer: Thomas Guillem
AudioService: fix "play as audio"
Add an option to force audio playback when loading a list.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=0adfe5c619385c0dbaf229eb21d98d7ca753b1c6
---
.../src/org/videolan/vlc/audio/AudioService.java | 10 ++++++----
.../videolan/vlc/audio/AudioServiceController.java | 17 +++++++++++++----
.../org/videolan/vlc/gui/video/VideoGridFragment.java | 2 +-
.../org/videolan/vlc/interfaces/IAudioService.aidl | 2 +-
4 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index 90bafe4..d01829b 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -119,6 +119,7 @@ public class AudioService extends Service {
private LibVLC mLibVLC;
private MediaWrapperListPlayer mMediaListPlayer;
+ private boolean mForceAudio = false;
private HashMap<IAudioServiceCallback, Integer> mCallback;
private EventHandler mEventHandler;
private OnAudioFocusChangeListener audioFocusListener;
@@ -618,7 +619,7 @@ public class AudioService extends Service {
};
private void handleVout() {
- if (mLibVLC.getVideoTracksCount() <= 0 || !hasCurrentMedia())
+ if (mForceAudio || mLibVLC.getVideoTracksCount() <= 0 || !hasCurrentMedia())
return;
final MediaWrapper mw = mMediaListPlayer.getMediaList().getMedia(mCurrentIndex);
if (mw == null)
@@ -1224,11 +1225,11 @@ public class AudioService extends Service {
}
mediaList.add(mediaWrapper);
}
- load(mediaList, position);
+ load(mediaList, position, false);
}
@Override
- public void load(List<MediaWrapper> mediaList, int position)
+ public void load(List<MediaWrapper> mediaList, int position, boolean forceAudio)
throws RemoteException {
Log.v(TAG, "Loading position " + ((Integer) position).toString() + " in " + mediaList.toString());
@@ -1239,6 +1240,7 @@ public class AudioService extends Service {
MediaWrapperList currentMediaList = mMediaListPlayer.getMediaList();
mPrevious.clear();
+ mForceAudio = forceAudio;
for (int i = 0; i < mediaList.size(); i++) {
currentMediaList.add(mediaList.get(i));
@@ -1333,7 +1335,7 @@ public class AudioService extends Service {
public void append(List<MediaWrapper> mediaList) throws RemoteException {
if (!hasCurrentMedia())
{
- load(mediaList, 0);
+ load(mediaList, 0, false);
return;
}
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java b/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java
index 6d10685..b45c79a 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java
@@ -296,10 +296,15 @@ public class AudioServiceController implements IAudioPlayerControl {
loadLocations(arrayList, 0);
}
- public void load(MediaWrapper media) {
+
+ public void load(MediaWrapper media, boolean forceAudio) {
ArrayList<MediaWrapper> arrayList = new ArrayList<MediaWrapper>();
arrayList.add(media);
- load(arrayList, 0);
+ load(arrayList, 0, forceAudio);
+ }
+
+ public void load(MediaWrapper media) {
+ load(media, false);
}
public void loadLocations(List<String> mediaPathList, int position) {
@@ -309,9 +314,13 @@ public class AudioServiceController implements IAudioPlayerControl {
}
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},
- new Object[]{mediaList, position});
+ new Class<?>[]{List.class, int.class, boolean.class},
+ new Object[]{mediaList, position, forceAudio});
}
public void append(MediaWrapper media) {
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 1e07ea9..e9904dd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -303,7 +303,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
}
protected void playAudio(MediaWrapper media) {
- mAudioController.load(media);
+ mAudioController.load(media, true);
}
private boolean handleContextItemSelected(MenuItem menu, int position) {
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl b/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
index 48f99b1..43749ed 100644
--- a/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
+++ b/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
@@ -31,7 +31,7 @@ interface IAudioService {
void shuffle();
void setTime(long time);
void loadLocations(in List<String> mediaPathList, int position);
- void load(in List<MediaWrapper> mediaList, int position);
+ void load(in List<MediaWrapper> mediaList, int position, boolean forceAudio);
void append(in List<MediaWrapper> mediaList);
void moveItem(int positionStart, int positionEnd);
void remove(int position);
More information about the Android
mailing list