Commit 0adfe5c6 authored by Thomas Guillem's avatar Thomas Guillem
Browse files

AudioService: fix "play as audio"

Add an option to force audio playback when loading a list.
parent 5ba52caa
......@@ -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;
}
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment