aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/service/DLNAController.java31
-rw-r--r--src/github/daneren2005/dsub/util/MediaRouteManager.java19
2 files changed, 34 insertions, 16 deletions
diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java
index 7e4f9ce7..dc92d6cf 100644
--- a/src/github/daneren2005/dsub/service/DLNAController.java
+++ b/src/github/daneren2005/dsub/service/DLNAController.java
@@ -54,6 +54,7 @@ import org.fourthline.cling.support.model.item.VideoItem;
import org.fourthline.cling.support.renderingcontrol.callback.SetVolume;
import org.seamless.util.MimeType;
+import java.io.File;
import java.net.URI;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -66,6 +67,7 @@ import github.daneren2005.dsub.domain.DLNADevice;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.serverproxy.FileProxy;
@@ -342,10 +344,16 @@ public class DLNAController extends RemoteController {
if(song.isVideo()) {
track = new VideoItem(song.getId(), song.getParent(), song.getTitle(), song.getArtist());
} else {
- String contentType = song.getTranscodedContentType();
+ String contentType = null;
+ if(song.getTranscodedContentType() != null) {
+ contentType = song.getTranscodedContentType();
+ } else if(song.getContentType() != null) {
+ contentType = song.getContentType();
+ }
+
MimeType mimeType;
// If we can parse the content type, use it instead of hard coding
- if(contentType.indexOf("/") != -1 && contentType.indexOf("/") != (contentType.length() - 1)) {
+ if(contentType != null && contentType.indexOf("/") != -1 && contentType.indexOf("/") != (contentType.length() - 1)) {
String[] typeParts = contentType.split("/");
mimeType = new MimeType(typeParts[0], typeParts[1]);
} else {
@@ -364,10 +372,21 @@ public class DLNAController extends RemoteController {
musicTrack.setOriginalTrackNumber(song.getTrack());
if(song.getCoverArt() != null) {
- String coverArt = musicService.getCoverArtUrl(downloadService, song);
- coverArt = Util.replaceInternalUrl(downloadService, coverArt);
- DIDLObject.Property.UPNP.ALBUM_ART_URI albumArtUri = new DIDLObject.Property.UPNP.ALBUM_ART_URI(URI.create(coverArt));
- musicTrack.addProperty(albumArtUri);
+ String coverArt = null;
+ if(proxy == null) {
+ coverArt = musicService.getCoverArtUrl(downloadService, song);
+ coverArt = Util.replaceInternalUrl(downloadService, coverArt);
+ } else {
+ File coverArtFile = FileUtil.getAlbumArtFile(downloadService, song);
+ if(coverArtFile != null && coverArtFile.exists()) {
+ coverArt = proxy.getPublicAddress(coverArtFile.getPath());
+ }
+ }
+
+ if(coverArt != null) {
+ DIDLObject.Property.UPNP.ALBUM_ART_URI albumArtUri = new DIDLObject.Property.UPNP.ALBUM_ART_URI(URI.create(coverArt));
+ musicTrack.addProperty(albumArtUri);
+ }
}
track = musicTrack;
diff --git a/src/github/daneren2005/dsub/util/MediaRouteManager.java b/src/github/daneren2005/dsub/util/MediaRouteManager.java
index 2d0c2a87..9aa54c4b 100644
--- a/src/github/daneren2005/dsub/util/MediaRouteManager.java
+++ b/src/github/daneren2005/dsub/util/MediaRouteManager.java
@@ -47,7 +47,7 @@ public class MediaRouteManager extends MediaRouter.Callback {
private MediaRouter router;
private MediaRouteSelector selector;
private List<MediaRouteProvider> providers = new ArrayList<MediaRouteProvider>();
- private List<MediaRouteProvider> offlineProviders = new ArrayList<MediaRouteProvider>();
+ private List<MediaRouteProvider> onlineProviders = new ArrayList<MediaRouteProvider>();
static {
try {
@@ -146,17 +146,10 @@ public class MediaRouteManager extends MediaRouter.Callback {
JukeboxRouteProvider jukeboxProvider = new JukeboxRouteProvider(downloadService);
router.addProvider(jukeboxProvider);
providers.add(jukeboxProvider);
- offlineProviders.add(jukeboxProvider);
-
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- DLNARouteProvider dlnaProvider = new DLNARouteProvider(downloadService);
- router.addProvider(dlnaProvider);
- providers.add(dlnaProvider);
- offlineProviders.add(dlnaProvider);
- }
+ onlineProviders.add(jukeboxProvider);
}
public void removeOnlineProviders() {
- for(MediaRouteProvider provider: offlineProviders) {
+ for(MediaRouteProvider provider: onlineProviders) {
router.removeProvider(provider);
}
}
@@ -165,6 +158,12 @@ public class MediaRouteManager extends MediaRouter.Callback {
if(!Util.isOffline(downloadService)) {
addOnlineProviders();
}
+
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ DLNARouteProvider dlnaProvider = new DLNARouteProvider(downloadService);
+ router.addProvider(dlnaProvider);
+ providers.add(dlnaProvider);
+ }
}
public void buildSelector() {
MediaRouteSelector.Builder builder = new MediaRouteSelector.Builder();