aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--subsonic-android/res/menu/select_song_context.xml5
-rw-r--r--subsonic-android/res/menu/select_song_context_offline.xml6
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java24
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java15
4 files changed, 49 insertions, 1 deletions
diff --git a/subsonic-android/res/menu/select_song_context.xml b/subsonic-android/res/menu/select_song_context.xml
index 95cf5eb3..4db229f2 100644
--- a/subsonic-android/res/menu/select_song_context.xml
+++ b/subsonic-android/res/menu/select_song_context.xml
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/song_menu_info"
+ android:title="@string/common.info"
+ />
<item
android:id="@+id/song_menu_play_now"
diff --git a/subsonic-android/res/menu/select_song_context_offline.xml b/subsonic-android/res/menu/select_song_context_offline.xml
index ab835525..8813d4a8 100644
--- a/subsonic-android/res/menu/select_song_context_offline.xml
+++ b/subsonic-android/res/menu/select_song_context_offline.xml
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/song_menu_info"
+ android:title="@string/common.info"
+ />
+
<item
android:id="@+id/song_menu_play_now"
android:title="@string/common.play_now"
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", "")));