[Android] AudioService: update the playlist when a media file has been removed
Adrien Maglo
git at videolan.org
Fri Feb 21 17:36:11 CET 2014
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Feb 21 17:36:01 2014 +0100| [55287184399545cecfc45b6206e2d17e6c8f9ce5] | committer: Adrien Maglo
AudioService: update the playlist when a media file has been removed
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=55287184399545cecfc45b6206e2d17e6c8f9ce5
---
vlc-android/src/org/videolan/libvlc/MediaList.java | 11 +++++++++++
vlc-android/src/org/videolan/vlc/AudioService.java | 5 +++++
.../src/org/videolan/vlc/AudioServiceController.java | 6 ++++++
.../videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java | 1 +
.../org/videolan/vlc/gui/audio/AudioBrowserFragment.java | 4 +++-
.../src/org/videolan/vlc/gui/video/VideoGridFragment.java | 7 ++++++-
.../src/org/videolan/vlc/interfaces/IAudioService.aidl | 1 +
7 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/libvlc/MediaList.java b/vlc-android/src/org/videolan/libvlc/MediaList.java
index f3de2f3..1889481 100644
--- a/vlc-android/src/org/videolan/libvlc/MediaList.java
+++ b/vlc-android/src/org/videolan/libvlc/MediaList.java
@@ -166,6 +166,17 @@ public class MediaList {
signal_list_event(EventHandler.CustomMediaListItemDeleted, position, uri);
}
+ public void remove(String location) {
+ for (int i = 0; i < mInternalList.size(); ++i) {
+ String uri = mInternalList.get(i).m.getLocation();
+ if (uri.equals(location)) {
+ mInternalList.remove(i);
+ signal_list_event(EventHandler.CustomMediaListItemDeleted, i, uri);
+ i--;
+ }
+ }
+ }
+
public int size() {
return mInternalList.size();
}
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 87d9685..54f74d4 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -1230,6 +1230,11 @@ public class AudioService extends Service {
}
@Override
+ public void removeLocation(String location) {
+ mLibVLC.getMediaList().remove(location);
+ }
+
+ @Override
public List<String> getMediaLocations() {
ArrayList<String> medias = new ArrayList<String>();
for (int i = 0; i < mLibVLC.getMediaList().size(); i++) {
diff --git a/vlc-android/src/org/videolan/vlc/AudioServiceController.java b/vlc-android/src/org/videolan/vlc/AudioServiceController.java
index a375bef..197c2ba 100644
--- a/vlc-android/src/org/videolan/vlc/AudioServiceController.java
+++ b/vlc-android/src/org/videolan/vlc/AudioServiceController.java
@@ -261,6 +261,12 @@ public class AudioServiceController implements IAudioPlayerControl {
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<String> getMediaLocations() {
List<String> def = new ArrayList<String>();
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 0c5b86e..776ce88 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -263,6 +263,7 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
mMediaLibrary.getMediaItems().remove(media);
mSongsAdapter.removeMedia(media);
mAlbumsAdapter.removeMedia(media);
+ mAudioController.removeLocation(media.getLocation());
}
});
alertDialog.show();
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 d2cf125..5a6c7e6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -255,7 +255,9 @@ public class AudioBrowserFragment extends SherlockFragment {
@Override
public void run(Object o) {
AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
- mMediaLibrary.getMediaItems().remove(listItem.mMediaList.get(0));
+ Media media = listItem.mMediaList.get(0);
+ mMediaLibrary.getMediaItems().remove(media);
+ mAudioController.removeLocation(media.getLocation());
updateLists();
}
});
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 44e52a4..c37ee35 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -99,6 +99,8 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
private Thumbnailer mThumbnailer;
private VideoGridAnimator mAnimator;
+ private AudioServiceController mAudioController;
+
/* All subclasses of Fragment must include a public empty constructor. */
public VideoGridFragment() { }
@@ -106,6 +108,8 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mAudioController = AudioServiceController.getInstance();
+
mVideoAdapter = new VideoListAdapter(getActivity(), this);
mMediaLibrary = MediaLibrary.getInstance(getActivity());
setListAdapter(mVideoAdapter);
@@ -270,7 +274,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
}
protected void playAudio(Media media) {
- AudioServiceController.getInstance().load(media.getLocation(), true);
+ mAudioController.load(media.getLocation(), true);
}
private boolean handleContextItemSelected(MenuItem menu, int position) {
@@ -301,6 +305,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
Media media = (Media) o;
mMediaLibrary.getMediaItems().remove(media);
mVideoAdapter.remove(media);
+ mAudioController.removeLocation(media.getLocation());
}
});
alertDialog.show();
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl b/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
index d03b015..24b556c 100644
--- a/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
+++ b/vlc-android/src/org/videolan/vlc/interfaces/IAudioService.aidl
@@ -33,6 +33,7 @@ interface IAudioService {
void append(in List<String> mediaPathList);
void moveItem(int positionStart, int positionEnd);
void remove(int position);
+ void removeLocation(String location);
List<String> getMediaLocations();
String getCurrentMediaLocation();
boolean isPlaying();
More information about the Android
mailing list