From dae987d86671333ba00b70c236484e5c67d00a8d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 26 Feb 2015 12:07:45 -0800 Subject: Use proxy for ChromeCast as well --- .../dsub/service/ChromeCastController.java | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java index f5def994..21ee6e13 100644 --- a/src/github/daneren2005/dsub/service/ChromeCastController.java +++ b/src/github/daneren2005/dsub/service/ChromeCastController.java @@ -45,6 +45,8 @@ import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.util.compat.CastCompat; import github.daneren2005.serverproxy.FileProxy; +import github.daneren2005.serverproxy.ServerProxy; +import github.daneren2005.serverproxy.WebProxy; /** * Created by owner on 2/9/14. @@ -61,7 +63,7 @@ public class ChromeCastController extends RemoteController { private boolean ignoreNextPaused = false; private String sessionId; - private FileProxy proxy; + private ServerProxy proxy; private String rootLocation; private RemoteMediaPlayer mediaPlayer; private double gain = 0.5; @@ -270,9 +272,26 @@ public class ChromeCastController extends RemoteController { proxy.start(); } - url = proxy.getPublicAddress(song.getId()); + // Offline song + if(song.getId().indexOf(rootLocation) != -1) { + url = proxy.getPublicAddress(song.getId()); + } else { + // Playing online song in offline mode + url = proxy.getPublicAddress(currentPlaying.getCompleteFile().getPath()); + } } else { - if(proxy != null) { + // Check if we want a proxy going still + if(Util.isCastProxy(downloadService)) { + if(proxy instanceof FileProxy) { + proxy.stop(); + proxy = null; + } + + if(proxy == null) { + proxy = new WebProxy(downloadService); + proxy.start(); + } + } else if(proxy != null) { proxy.stop(); proxy = null; } @@ -282,6 +301,11 @@ public class ChromeCastController extends RemoteController { } else { url = musicService.getMusicUrl(downloadService, song, currentPlaying.getBitRate()); } + + // If proxy is going, it is a WebProxy + if(proxy != null) { + url = proxy.getPublicAddress(url); + } } // Setup song/video information @@ -296,8 +320,14 @@ public class ChromeCastController extends RemoteController { meta.putString(MediaMetadata.KEY_ALBUM_TITLE, song.getAlbum()); String coverArt = ""; - if(proxy == null) { + if(proxy == null || proxy instanceof WebProxy) { coverArt = musicService.getCoverArtUrl(downloadService, song); + + // If proxy is going, it is a web proxy + if(proxy != null) { + coverArt = proxy.getPublicAddress(coverArt); + } + meta.addImage(new WebImage(Uri.parse(coverArt))); } else { File coverArtFile = FileUtil.getAlbumArtFile(downloadService, song); -- cgit v1.2.3