aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-08-30 11:32:19 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-08-30 11:32:19 -0700
commit5949caafe3d598268373ceeda8cf416dc96f6ac6 (patch)
treed6b687cbf6198a85e6e60691ebbc28009793a277 /src
parent880e67c505338d7c969ce1fd95e6a086ac4cefdd (diff)
downloaddsub-5949caafe3d598268373ceeda8cf416dc96f6ac6.tar.gz
dsub-5949caafe3d598268373ceeda8cf416dc96f6ac6.tar.bz2
dsub-5949caafe3d598268373ceeda8cf416dc96f6ac6.zip
Don't immediately load metadata on offline playlist
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/OfflineMusicService.java37
1 files changed, 7 insertions, 30 deletions
diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java
index 1221df5c..3bab2fc8 100644
--- a/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -32,7 +32,6 @@ import java.util.Set;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
-import android.media.MediaMetadataRetriever;
import android.util.Log;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.Genre;
@@ -147,7 +146,10 @@ public class OfflineMusicService extends RESTMusicService {
return FileUtil.getBaseName(name);
}
- private MusicDirectory.Entry createEntry(Context context, File file, String name) {
+ private MusicDirectory.Entry createEntry(Context context, File file, String name) {
+ return createEntry(context, file, name, true);
+ }
+ private MusicDirectory.Entry createEntry(Context context, File file, String name, boolean load) {
MusicDirectory.Entry entry = new MusicDirectory.Entry();
entry.setDirectory(file.isDirectory());
entry.setId(file.getPath());
@@ -179,33 +181,8 @@ public class OfflineMusicService extends RESTMusicService {
}
}
- try {
- MediaMetadataRetriever metadata = new MediaMetadataRetriever();
- metadata.setDataSource(file.getAbsolutePath());
- String discNumber = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER);
- if(discNumber == null) {
- discNumber = "1/1";
- }
- int slashIndex = discNumber.indexOf("/");
- if(slashIndex > 0) {
- discNumber = discNumber.substring(0, slashIndex);
- }
- entry.setDiscNumber(Integer.parseInt(discNumber));
- String bitrate = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE);
- entry.setBitRate(Integer.parseInt((bitrate != null) ? bitrate : "0") / 1000);
- String length = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
- entry.setDuration(Integer.parseInt(length) / 1000);
- String artist = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
- if(artist != null) {
- entry.setArtist(artist);
- }
- String album = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
- if(album != null) {
- entry.setAlbum(album);
- }
- metadata.release();
- } catch(Exception e) {
- Log.i(TAG, "Device doesn't properly support MediaMetadataRetreiver");
+ if(load) {
+ entry.loadMetadata(file);
}
}
@@ -427,7 +404,7 @@ public class OfflineMusicService extends RESTMusicService {
File entryFile = new File(line);
String entryName = getName(entryFile);
if(entryFile.exists() && entryName != null){
- playlist.addChild(createEntry(context, entryFile, entryName));
+ playlist.addChild(createEntry(context, entryFile, entryName, false));
}
}