Fixed #130: Google cast icon is not visible.

Fixed Google cast icon is not visible on newer Chrome versions.
Also fixed cast is not working because local ip address lookup
is not performing.

Signed-off-by: Egor Berdnikov <egorr.berd@gmail.com>
master
Egor Berdnikov 8 years ago
parent 7191d804ec
commit af06f9bfd7
  1. 5
      libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java
  2. 10
      libresonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp
  3. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/playQueueCast.jsp
  4. 43
      libresonic-main/src/main/webapp/script/cast_sender-v1.js

@ -217,6 +217,10 @@ public class SettingsService {
private List<MusicFolder> cachedMusicFolders;
private final ConcurrentMap<String, List<MusicFolder>> cachedMusicFoldersPerUser = new ConcurrentHashMap<String, List<MusicFolder>>();
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
private static final long LOCAL_IP_LOOKUP_DELAY_SECONDS = 60;
private String localIpAddress;
private void removeObseleteProperties() {
@ -1285,6 +1289,7 @@ public class SettingsService {
localIpAddress = Util.getLocalIpAddress();
}
};
executor.scheduleWithFixedDelay(task,0, LOCAL_IP_LOOKUP_DELAY_SECONDS, TimeUnit.SECONDS);
}
public void setInternetRadioDao(InternetRadioDao internetRadioDao) {

@ -11,7 +11,6 @@
<script type="text/javascript" src="<c:url value="/dwr/engine.js"/>"></script>
<script type="text/javascript" src="<c:url value="/dwr/util.js"/>"></script>
<script type="text/javascript" src="<c:url value="/script/jwplayer-5.10.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/script/cast_sender-v1.js"/>"></script>
<%@ include file="playQueueCast.jsp" %>
<link type="text/css" rel="stylesheet" href="<c:url value="/script/webfx/luna.css"/>">
<style type="text/css">
@ -846,4 +845,13 @@
<div id="dialog-select-playlist-list"></div>
</div>
<script type="text/javascript">
window['__onGCastApiAvailable'] = function(isAvailable) {
if (isAvailable) {
CastPlayer.initializeCastPlayer();
}
};
</script>
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
</body></html>

@ -7,8 +7,6 @@
this.castSession = null;
this.mediaSession = null;
this.volume = 1.0;
this.initializeCastPlayer();
};
CastPlayer.prototype.initializeCastPlayer = function () {

@ -1,43 +0,0 @@
(function() {var chrome = window.chrome || {};
chrome.cast = chrome.cast || {};
chrome.cast.media = chrome.cast.media || {};
chrome.cast.ApiBootstrap_ = function() {
};
chrome.cast.ApiBootstrap_.EXTENSION_IDS = ["boadgeojelhgndaghljhdicfkmllpafd", "dliochdbjfkdbacpmhlcpmleaejidimm", "hfaagokkkhdbgiakmmlclaapfelnkoah", "fmfcbgogabcbclcofgocippekhfcmgfj", "enhhojjnijigcajfphajepfemndkmdlo"];
chrome.cast.ApiBootstrap_.findInstalledExtension_ = function(callback) {
chrome.cast.ApiBootstrap_.findInstalledExtensionHelper_(0, callback);
};
chrome.cast.ApiBootstrap_.findInstalledExtensionHelper_ = function(index, callback) {
index == chrome.cast.ApiBootstrap_.EXTENSION_IDS.length ? callback(null) : chrome.cast.ApiBootstrap_.isExtensionInstalled_(chrome.cast.ApiBootstrap_.EXTENSION_IDS[index], function(installed) {
installed ? callback(chrome.cast.ApiBootstrap_.EXTENSION_IDS[index]) : chrome.cast.ApiBootstrap_.findInstalledExtensionHelper_(index + 1, callback);
});
};
chrome.cast.ApiBootstrap_.getCastSenderUrl_ = function(extensionId) {
return "chrome-extension://" + extensionId + "/cast_sender.js";
};
chrome.cast.ApiBootstrap_.isExtensionInstalled_ = function(extensionId, callback) {
var xmlhttp = new XMLHttpRequest;
xmlhttp.onreadystatechange = function() {
4 == xmlhttp.readyState && 200 == xmlhttp.status && callback(!0);
};
xmlhttp.onerror = function() {
callback(!1);
};
xmlhttp.open("GET", chrome.cast.ApiBootstrap_.getCastSenderUrl_(extensionId), !0);
xmlhttp.send();
};
chrome.cast.ApiBootstrap_.findInstalledExtension_(function(extensionId) {
if (extensionId) {
console.log("Found cast extension: " + extensionId);
chrome.cast.extensionId = extensionId;
var apiScript = document.createElement("script");
apiScript.src = chrome.cast.ApiBootstrap_.getCastSenderUrl_(extensionId);
(document.head || document.documentElement).appendChild(apiScript);
} else {
var msg = "No cast extension found";
console.log(msg);
var callback = window.__onGCastApiAvailable;
callback && "function" == typeof callback && callback(!1, msg);
}
});
})();
Loading…
Cancel
Save