diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-12-14 19:58:32 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-12-14 19:58:32 -0800 |
commit | c28f908a1fab16ee9ac273a5fc226d5abc02ba01 (patch) | |
tree | 18139bc84bcd84b0de85ec8888ad84f438662188 /subsonic-android/src/github/daneren2005 | |
parent | f03dc76a98aa5d74fab09816644a85a80441c5e2 (diff) | |
download | dsub-c28f908a1fab16ee9ac273a5fc226d5abc02ba01.tar.gz dsub-c28f908a1fab16ee9ac273a5fc226d5abc02ba01.tar.bz2 dsub-c28f908a1fab16ee9ac273a5fc226d5abc02ba01.zip |
Added song details in context menu
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java | 24 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java | 15 |
2 files changed, 38 insertions, 1 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index 4ccdd6d6..6ef17a3b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -313,6 +313,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity { case R.id.song_menu_play_external: playExternalPlayer(entry); break; + case R.id.song_menu_info: + displaySongInfo(entry); + break; /*case R.id.song_menu_stream_external: streamExternalPlayer(entry); break;*/ @@ -728,4 +731,25 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } }.execute(); } + + private void displaySongInfo(final MusicDirectory.Entry song) { + String msg = "Artist: " + song.getArtist() + "\nAlbum: " + song.getAlbum(); + if(!song.getGenre().isEmpty()) { + msg += "\nGenre: " + song.getGenre(); + } + if(song.getYear() != null && song.getYear() != 0) { + msg += "\nYear: " + song.getYear(); + } + msg += "\nFormat: " + song.getSuffix(); + if(song.getBitRate() != null && song.getBitRate() != 0) { + msg += "\nBitrate: " + song.getBitRate() + " kpbs"; + } + msg += "\nSize: " + Util.formatBytes(song.getSize()); + + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setTitle(song.getTitle()) + .setMessage(msg) + .show(); + } } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index a12a169e..d0b0f93c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -34,6 +34,7 @@ import java.util.Set; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.media.MediaMetadataRetriever; import android.util.Log; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.Indexes; @@ -110,7 +111,7 @@ 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) { MusicDirectory.Entry entry = new MusicDirectory.Entry(); entry.setDirectory(file.isDirectory()); entry.setId(file.getPath()); @@ -121,6 +122,18 @@ public class OfflineMusicService extends RESTMusicService { if (file.isFile()) { entry.setArtist(file.getParentFile().getParentFile().getName()); entry.setAlbum(file.getParentFile().getName()); + + try { + MediaMetadataRetriever metadata = new MediaMetadataRetriever(); + metadata.setDataSource(file.getAbsolutePath()); + entry.setGenre(metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE)); + String bitrate = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE); + entry.setBitRate(Integer.parseInt((bitrate != null) ? bitrate : "0") / 1000); + String year = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_YEAR); + entry.setYear(Integer.parseInt((year != null) ? year : "0")); + } catch(Exception e) { + Log.i(TAG, "Device doesn't properly support MediaMetadataRetreiver"); + } } entry.setTitle(name); entry.setSuffix(FileUtil.getExtension(file.getName().replace(".complete", ""))); |