diff options
8 files changed, 61 insertions, 10 deletions
diff --git a/subsonic-android/res/layout/select_album_header.xml b/subsonic-android/res/layout/select_album_header.xml index 3af34a99..2bf74110 100644 --- a/subsonic-android/res/layout/select_album_header.xml +++ b/subsonic-android/res/layout/select_album_header.xml @@ -24,7 +24,6 @@ android:paddingTop="20dip" android:paddingBottom="8dip" android:paddingRight="4dip" - android:textColor="@color/mediaControlForeground" android:textAppearance="?android:attr/textAppearanceMedium" android:textStyle="bold" android:singleLine="true" diff --git a/subsonic-android/res/values/colors.xml b/subsonic-android/res/values/colors.xml index d17486a1..0ce98fc9 100644 --- a/subsonic-android/res/values/colors.xml +++ b/subsonic-android/res/values/colors.xml @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <color name="lightBackground">#F1F0E6</color> - <color name="mediaControlBackground">#000000</color> - <color name="mediaControlForeground">#F0F0F0</color> <color name="dividerColor">#FF33B5E5</color> <color name="appwidget_text">#FFFFFF</color> <color name="notificationArtist">#434343</color> diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java index 3fa38bdf..5ab7ad70 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java @@ -34,6 +34,7 @@ import github.daneren2005.dsub.util.CancellableTask; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.util.CacheCleaner; +import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -59,6 +60,7 @@ public class DownloadFile { private boolean isPlaying = false; private boolean saveWhenDone = false; private boolean completeWhenDone = false; + private Integer contentLength = null; public DownloadFile(Context context, MusicDirectory.Entry song, boolean save) { this.context = context; @@ -89,6 +91,10 @@ public class DownloadFile { } return song.getBitRate() == null ? 160 : song.getBitRate(); } + + public Integer getContentLength() { + return contentLength; + } public synchronized void download() { FileUtil.createDirectoryForParent(saveFile); @@ -270,6 +276,14 @@ public class DownloadFile { if(compare) { // Attempt partial HTTP GET, appending to the file if it exists. HttpResponse response = musicService.getDownloadInputStream(context, song, partialFile.length(), bitRate, DownloadTask.this); + Header contentLengthHeader = response.getFirstHeader("Content-Length"); + if(contentLengthHeader != null) { + String contentLengthString = contentLengthHeader.getValue(); + if(contentLengthString != null) { + Log.i(TAG, "Content Length: " + contentLengthString); + contentLength = Integer.parseInt(contentLengthString); + } + } in = response.getEntity().getContent(); boolean partial = response.getStatusLine().getStatusCode() == HttpStatus.SC_PARTIAL_CONTENT; if (partial) { diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index ba8ea1e4..4c02a831 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -282,16 +282,22 @@ public class DownloadServiceImpl extends Service implements DownloadService { } revision++; } else { + int size = size(); + int index = getCurrentPlayingIndex(); for (MusicDirectory.Entry song : songs) { DownloadFile downloadFile = new DownloadFile(this, song, save); downloadList.add(downloadFile); } + if(!autoplay && (size - 1) == index) { + setNextPlaying(); + } revision++; } updateJukeboxPlaylist(); - if(shuffle) + if(shuffle) { shuffle(); + } if (autoplay) { play(0); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 0c7dba27..59895a7d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -152,6 +152,9 @@ public class OfflineMusicService extends RESTMusicService { entry.setParent(file.getParent()); entry.setSize(file.length()); String root = FileUtil.getMusicDirectory(context).getPath(); + if(!file.getParentFile().getParentFile().getPath().equals(root)) { + entry.setGrandParent(file.getParentFile().getParent()); + } entry.setPath(file.getPath().replaceFirst("^" + root + "/" , "")); String title = name; if (file.isFile()) { diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index ee8a384c..75867fdc 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -274,6 +274,19 @@ public class RESTMusicService implements MusicService { @Override public MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception { + SharedPreferences prefs = Util.getPreferences(context); + String cacheLocn = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null); + if(id.indexOf(cacheLocn) != -1) { + String search = Util.parseOfflineIDSearch(context, id, cacheLocn); + SearchCritera critera = new SearchCritera(search, 1, 1, 0); + SearchResult result = searchNew(critera, context, progressListener); + if(result.getArtists().size() == 1) { + id = result.getArtists().get(0).getId(); + } else if(result.getAlbums().size() == 1) { + id = result.getAlbums().get(0).getId(); + } + } + Reader reader = getReader(context, progressListener, "getMusicDirectory", null, "id", id); try { return new MusicDirectoryParser(context).parse(name, reader, progressListener); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/StreamProxy.java b/subsonic-android/src/github/daneren2005/dsub/service/StreamProxy.java index 13dbf479..24c1b201 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/StreamProxy.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/StreamProxy.java @@ -157,12 +157,20 @@ public class StreamProxy implements Runnable { Log.i(TAG, "Streaming song in background");
DownloadFile downloadFile = downloadService.getCurrentPlaying();
MusicDirectory.Entry song = downloadFile.getSong();
- long fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8;
- Log.i(TAG, "Streaming fileSize: " + fileSize);
// Create HTTP header
String headers = "HTTP/1.0 200 OK\r\n";
headers += "Content-Type: " + "application/octet-stream" + "\r\n";
+
+ Integer contentLength = downloadFile.getContentLength();
+ long fileSize;
+ if(contentLength == null) {
+ fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8;
+ } else {
+ fileSize = contentLength;
+ headers += "Content-Length: " + fileSize + "\r\n";
+ }
+ Log.i(TAG, "Streaming fileSize: " + fileSize);
headers += "Connection: close\r\n";
headers += "\r\n";
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 3ad4c623..98b9fc42 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -378,11 +378,21 @@ public final class Util { name = index == -1 ? name : name.substring(0, index); String[] details = name.split("/"); - String artist = "artist:\"" + details[0] + "\""; String title = details[details.length - 1]; - title = "title:\"" + title.substring(title.indexOf('-') + 1) + "\""; - - name = artist + " AND " + title; + if(index == -1) { + if(details.length > 1) { + String artist = "artist:\"" + details[details.length - 2] + "\""; + String simpleArtist = "artist:\"" + title + "\""; + title = "album:\"" + title + "\""; + name = "(" + artist + " AND " + title + ")" + " OR " + simpleArtist; + } else { + name = "artist:\"" + title + "\""; + } + } else { + String artist = "artist:\"" + details[details.length - 3] + "\""; + title = "title:\"" + title.substring(title.indexOf('-') + 1) + "\""; + name = artist + " AND " + title; + } return name; } |