[Android] Media: remove dependency on MediaDatabase in ctor
Edward Wang
git at videolan.org
Tue Nov 5 23:47:19 CET 2013
vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Tue Nov 5 16:21:25 2013 -0500| [c4538b5a1acf09616d0fdfcd4f4fdaa1084cdb7b] | committer: Edward Wang
Media: remove dependency on MediaDatabase in ctor
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c4538b5a1acf09616d0fdfcd4f4fdaa1084cdb7b
---
vlc-android/src/org/videolan/libvlc/MediaList.java | 4 ++--
vlc-android/src/org/videolan/vlc/AudioService.java | 4 ++--
vlc-android/src/org/videolan/vlc/Media.java | 9 +--------
vlc-android/src/org/videolan/vlc/MediaLibrary.java | 6 +++++-
vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java | 2 +-
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 2 +-
6 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/vlc-android/src/org/videolan/libvlc/MediaList.java b/vlc-android/src/org/videolan/libvlc/MediaList.java
index d050dce..065cd49 100644
--- a/vlc-android/src/org/videolan/libvlc/MediaList.java
+++ b/vlc-android/src/org/videolan/libvlc/MediaList.java
@@ -59,7 +59,7 @@ public class MediaList {
}
public void add(String mrl) {
- add(new Media(mLibVLC, mrl, false));
+ add(new Media(mLibVLC, mrl));
}
public void add(Media media) {
add(media, false, false);
@@ -117,7 +117,7 @@ public class MediaList {
private native void loadPlaylist(LibVLC libvlc_instance, String mrl, ArrayList<String> items);
public void insert(int position, String mrl) {
- insert(position, new Media(mLibVLC, mrl, false));
+ insert(position, new Media(mLibVLC, mrl));
}
public void insert(int position, Media media) {
mInternalList.add(position, new MediaHolder(media));
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 064b540..43d6f49 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -947,7 +947,7 @@ public class AudioService extends Service {
continue;
}
Log.v(TAG, "Creating on-the-fly Media object for " + location);
- media = new Media(mLibVLC, location, false);
+ media = new Media(mLibVLC, location);
}
mediaList.add(media, noVideo);
}
@@ -1033,7 +1033,7 @@ public class AudioService extends Service {
continue;
}
Log.v(TAG, "Creating on-the-fly Media object for " + location);
- media = new Media(mLibVLC, location, false);
+ media = new Media(mLibVLC, location);
}
mLibVLC.getMediaList().add(media);
}
diff --git a/vlc-android/src/org/videolan/vlc/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
index 0be3864..93192c8 100644
--- a/vlc-android/src/org/videolan/vlc/Media.java
+++ b/vlc-android/src/org/videolan/vlc/Media.java
@@ -132,9 +132,8 @@ public class Media implements Comparable<Media> {
* Create a new Media
* @param libVLC A pointer to the libVLC instance. Should not be NULL
* @param URI The URI of the media.
- * @param addToDb Should it be added to the file database?
*/
- public Media(LibVLC libVLC, String URI, Boolean addToDb) {
+ public Media(LibVLC libVLC, String URI) {
if(libVLC == null)
throw new NullPointerException("libVLC was null");
@@ -144,12 +143,6 @@ public class Media implements Comparable<Media> {
TrackInfo[] tracks = libVLC.readTracksInfo(mLocation);
extractTrackInfo(tracks);
-
- if (addToDb) {
- // Add this item to database
- MediaDatabase db = MediaDatabase.getInstance(VLCApplication.getAppContext());
- db.addMedia(this);
- }
}
private void extractTrackInfo(TrackInfo[] tracks) {
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index 024be4b..e7a53fe 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -320,7 +320,11 @@ public class MediaLibrary {
} else {
mItemListLock.writeLock().lock();
// create new media item
- mItemList.add(new Media(libVlcInstance, fileURI, true));
+ Media m = new Media(libVlcInstance, fileURI);
+ mItemList.add(m);
+ // Add this item to database
+ MediaDatabase db = MediaDatabase.getInstance(VLCApplication.getAppContext());
+ db.addMedia(m);
mItemListLock.writeLock().unlock();
}
if (isStopping) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
index 5721d6c..400f0b0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
@@ -298,7 +298,7 @@ public class DirectoryAdapter extends BaseAdapter {
String holderText = "";
if(selectedNode.isFile()) {
Log.d(TAG, "Loading media " + selectedNode.name);
- Media m = new Media(LibVLC.getExistingInstance(), getMediaLocation(position), false);
+ Media m = new Media(LibVLC.getExistingInstance(), getMediaLocation(position));
holder.title.setText(m.getTitle());
holderText = m.getSubtitle();
} else
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 fdb6456..4c5dc01 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1519,7 +1519,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mLibVLC.playIndex(savedIndexPosition);
} else if (mLocation != null && mLocation.length() > 0 && !dontParse) {
mLibVLC.setMediaList();
- mLibVLC.getMediaList().add(new Media(mLibVLC, mLocation, false));
+ mLibVLC.getMediaList().add(new Media(mLibVLC, mLocation));
savedIndexPosition = mLibVLC.getMediaList().size() - 1;
mLibVLC.playIndex(savedIndexPosition);
}
More information about the Android
mailing list