diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-05-28 19:53:41 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-05-28 19:53:41 -0700 |
commit | 9e14459fb8691624febe20e9df3d35518c6ec422 (patch) | |
tree | d3929ade4f1bc59b212dffa98fa2f1b06a2b9e8d /subsonic-android | |
parent | b5e059531040c7edfc89028942d2daf3bbb2d5d7 (diff) | |
download | dsub-9e14459fb8691624febe20e9df3d35518c6ec422.tar.gz dsub-9e14459fb8691624febe20e9df3d35518c6ec422.tar.bz2 dsub-9e14459fb8691624febe20e9df3d35518c6ec422.zip |
Moved metadata parsing back to createEntry, added disc number parsing
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java | 21 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/view/SongView.java | 17 |
2 files changed, 21 insertions, 17 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 5f9aaf96..36e97c07 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -162,6 +162,27 @@ public class OfflineMusicService extends RESTMusicService { // Failed parseInt, just means track filled out } } + + 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); + metadata.release(); + } catch(Exception e) { + Log.i(TAG, "Device doesn't properly support MediaMetadataRetreiver"); + } } entry.setTitle(title); diff --git a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java index 51927304..40bedad6 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java @@ -72,23 +72,6 @@ public class SongView extends UpdateView implements Checkable { public void setSong(MusicDirectory.Entry song, boolean checkable) { this.song = song; - if(Util.isOffline(context)) { - DownloadFile downloadFile = new DownloadFile(context, song, false); - File file = downloadFile.getCompleteFile(); - if(file.exists()) { - try { - MediaMetadataRetriever metadata = new MediaMetadataRetriever(); - metadata.setDataSource(file.getAbsolutePath()); - String bitrate = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE); - song.setBitRate(Integer.parseInt((bitrate != null) ? bitrate : "0") / 1000); - String length = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); - song.setDuration(Integer.parseInt(length) / 1000); - } catch(Exception e) { - Log.i(TAG, "Device doesn't properly support MediaMetadataRetreiver"); - } - } - } - StringBuilder artist = new StringBuilder(40); String bitRate = null; |