[Android] [PATCH] AudioService: always open media with NO_VIDEO flags
Thomas Guillem
thomas at gllm.fr
Wed Apr 29 09:38:57 CEST 2015
Since we don't have a surface, it's useless to try video.
If we switch to VideoPlayer, the video will be reactivated by setting the video
track to 0.
---
.../org/videolan/vlc/MediaWrapperListPlayer.java | 19 ++++++++++++++-----
.../src/org/videolan/vlc/audio/AudioService.java | 21 +++++++++------------
.../videolan/vlc/audio/AudioServiceController.java | 14 +++++---------
.../vlc/gui/audio/AudioBrowserFragment.java | 4 ++--
.../vlc/gui/browser/BaseBrowserFragment.java | 2 +-
.../videolan/vlc/gui/video/VideoGridFragment.java | 2 +-
.../org/videolan/vlc/interfaces/IAudioService.aidl | 2 +-
vlc-android/src/org/videolan/vlc/util/Util.java | 2 +-
.../vlc/gui/tv/audioplayer/AudioPlayerActivity.java | 2 +-
9 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java b/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java
index 562be13..6484177 100644
--- a/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/MediaWrapperListPlayer.java
@@ -53,21 +53,30 @@ public class MediaWrapperListPlayer {
* Play a media from the media list (playlist)
*
* @param position The index of the media
- * @param paused start the media paused
+ * @param flags LibVLC.MEDIA_* flags
*/
- public void playIndex(int position, boolean paused) {
+ public void playIndex(int position, int flags) {
String mrl = mMediaList.getMRL(position);
if (mrl == null)
return;
- final int pausedFlag = paused ? LibVLC.MEDIA_PAUSED : 0;
final MediaWrapper media = mMediaList.getMedia(position);
- String[] options = mLibVLC.getMediaOptions(pausedFlag | (media != null ? media.getFlags() : 0));
+ String[] options = mLibVLC.getMediaOptions(flags | (media != null ? media.getFlags() : 0));
mPlayerIndex = position;
mLibVLC.playMRL(mrl, options);
}
+ /**
+ * Play a media from the media list (playlist)
+ *
+ * @param position The index of the media
+ * @param paused start the media paused
+ */
+ public void playIndex(int position, boolean paused) {
+ playIndex(position, paused ? LibVLC.MEDIA_PAUSED : 0);
+ }
+
public void playIndex(int position) {
- playIndex(position, false);
+ playIndex(position, 0);
}
/**
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index 490924c..e7b7b8c 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -582,7 +582,7 @@ public class AudioService extends Service {
if (mNextIndex != -1)
next();
else if (mCurrentIndex != -1) {
- mMediaListPlayer.playIndex(mCurrentIndex);
+ mMediaListPlayer.playIndex(mCurrentIndex, LibVLC.MEDIA_NO_VIDEO);
executeOnMediaPlayedAdded();
} else
stop();
@@ -621,7 +621,7 @@ public class AudioService extends Service {
if (mLibVLC.getVideoTracksCount() <= 0 || !hasCurrentMedia())
return;
final MediaWrapper mw = mMediaListPlayer.getMediaList().getMedia(mCurrentIndex);
- if (mw == null || (mw.getFlags() & LibVLC.MEDIA_NO_VIDEO) != 0)
+ if (mw == null)
return;
Log.i(TAG, "Obtained video track");
@@ -948,7 +948,7 @@ public class AudioService extends Service {
return;
}
- mMediaListPlayer.playIndex(mCurrentIndex);
+ mMediaListPlayer.playIndex(mCurrentIndex, LibVLC.MEDIA_NO_VIDEO);
executeOnMediaPlayedAdded();
mHandler.sendEmptyMessage(SHOW_PROGRESS);
@@ -1013,7 +1013,7 @@ public class AudioService extends Service {
return;
}
- mMediaListPlayer.playIndex(mCurrentIndex);
+ mMediaListPlayer.playIndex(mCurrentIndex, LibVLC.MEDIA_NO_VIDEO);
executeOnMediaPlayedAdded();
mHandler.sendEmptyMessage(SHOW_PROGRESS);
setUpRemoteControlClient();
@@ -1199,11 +1199,10 @@ public class AudioService extends Service {
*
* @param mediaPathList A list of locations to load
* @param position The position to start playing at
- * @param noVideo True to disable video, false otherwise
* @throws RemoteException
*/
@Override
- public void load(List<String> mediaPathList, int position, boolean noVideo)
+ public void load(List<String> mediaPathList, int position)
throws RemoteException {
Log.v(TAG, "Loading position " + ((Integer)position).toString() + " in " + mediaPathList.toString());
@@ -1231,8 +1230,6 @@ public class AudioService extends Service {
media.release();
mediaWrapper = new MediaWrapper(media);
}
- if (noVideo)
- mediaWrapper.addFlags(LibVLC.MEDIA_NO_VIDEO);
mediaList.add(mediaWrapper);
}
@@ -1250,7 +1247,7 @@ public class AudioService extends Service {
// Add handler after loading the list
mMediaListPlayer.getMediaList().addEventListener(mListEventListener);
- mMediaListPlayer.playIndex(mCurrentIndex);
+ mMediaListPlayer.playIndex(mCurrentIndex, LibVLC.MEDIA_NO_VIDEO);
executeOnMediaPlayedAdded();
mHandler.sendEmptyMessage(SHOW_PROGRESS);
setUpRemoteControlClient();
@@ -1282,7 +1279,7 @@ public class AudioService extends Service {
}
mEventHandler.addHandler(mVlcEventHandler);
- mMediaListPlayer.playIndex(mCurrentIndex);
+ mMediaListPlayer.playIndex(mCurrentIndex, LibVLC.MEDIA_NO_VIDEO);
executeOnMediaPlayedAdded();
mHandler.sendEmptyMessage(SHOW_PROGRESS);
setUpRemoteControlClient();
@@ -1325,7 +1322,7 @@ public class AudioService extends Service {
public void append(List<String> mediaLocationList) throws RemoteException {
if (!hasCurrentMedia())
{
- load(mediaLocationList, 0, false);
+ load(mediaLocationList, 0);
return;
}
@@ -1545,7 +1542,7 @@ public class AudioService extends Service {
int position = Math.max(0, mediaPathList.indexOf(currentMedia));
// load playlist
try {
- mInterface.load(mediaPathList, position, false);
+ mInterface.load(mediaPathList, position);
} catch (RemoteException e) {
e.printStackTrace();
}
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java b/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java
index bf70219..9906159 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioServiceController.java
@@ -290,20 +290,16 @@ public class AudioServiceController implements IAudioPlayerControl {
}
}
- public void load(List<String> mediaPathList, int position) {
- load(mediaPathList, position, false);
- }
-
- public void load(String mediaPath, boolean noVideo) {
+ public void load(String mediaPath) {
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add(mediaPath);
- load(arrayList, 0, noVideo);
+ load(arrayList, 0);
}
- public void load(List<String> mediaPathList, int position, boolean noVideo) {
+ public void load(List<String> mediaPathList, int position) {
remoteProcedureCall(mAudioServiceBinder, Void.class, (Void)null, "load",
- new Class<?>[] { List.class, int.class, boolean.class },
- new Object[] { mediaPathList, position, noVideo } );
+ new Class<?>[] { List.class, int.class },
+ new Object[] { mediaPathList, position } );
}
public void append(String mediaPath) {
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 15c854f..5b84722 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -365,10 +365,10 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
ArrayList<MediaWrapper> mediaList = mPlaylistAdapter.getItem(p).mMediaList;
if (mediaList.size() == 1) {
String mediaLocation = mediaList.get(0).getLocation();
- mAudioController.load(mediaLocation, true);
+ mAudioController.load(mediaLocation);
} else {
ArrayList<String> mediaLocations = mPlaylistAdapter.getLocations(p);
- mAudioController.load(mediaLocations, 0, true);
+ mAudioController.load(mediaLocations, 0);
}
}
};
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 d9c898c..a1ae077 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -404,7 +404,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
alertDialog.show();
return true;
case R.id.directory_view_play_audio:
- AudioServiceController.getInstance().load(mw.getLocation(), true);
+ AudioServiceController.getInstance().load(mw.getLocation());
return true;
case R.id.directory_view_play_video:
VideoPlayerActivity.start(getActivity(), mw.getLocation());
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 2f30b22..8e5acf5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -302,7 +302,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
}
protected void playAudio(MediaWrapper media) {
- mAudioController.load(media.getLocation(), true);
+ mAudioController.load(media.getLocation());
}
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 d091362..3076de8 100644
--- a/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
+++ b/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
@@ -30,7 +30,7 @@ interface IAudioService {
void previous();
void shuffle();
void setTime(long time);
- void load(in List<String> mediaPathList, int position, boolean noVideo);
+ void load(in List<String> mediaPathList, int position);
void append(in List<String> mediaPathList);
void moveItem(int positionStart, int positionEnd);
void remove(int position);
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index f574406..536b046 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -241,7 +241,7 @@ public class Util {
* (for example, RTSP and TS streaming) where ES can be
* dynamically adapted rather than a simple scan.
*/
- c.load(uri, false);
+ c.load(uri);
}
};
task.execute();
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 9b3e169..3f56de4 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
@@ -123,7 +123,7 @@ public class AudioPlayerActivity extends Activity implements AudioServiceControl
public void onConnectionSuccess() {
ArrayList<String> medialocations = (ArrayList<String>) mAudioController.getMediaLocations();
if (!mLocations.isEmpty() && !mLocations.equals(medialocations)) {
- mAudioController.load(mLocations, 0, true);
+ mAudioController.load(mLocations, 0);
} else {
mLocations = medialocations;
update();
--
2.1.4
More information about the Android
mailing list