mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed soundcloud loading-issue on initial channel-load
This commit is contained in:
@@ -18,15 +18,17 @@ var Channel = {
|
||||
} else {
|
||||
if(!api_key.hasOwnProperty("soundcloud")) soundcloud_enabled = false;
|
||||
else {
|
||||
SC.initialize({
|
||||
/*SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
});*/
|
||||
}
|
||||
if(cast_ready_connect || chromecastAvailable || chromecastReady) {
|
||||
Helper.addClass(".volume-container", "volume-container-cast");
|
||||
}
|
||||
if(!embed) {
|
||||
console.log("qq");
|
||||
console.log(Helper.computedStyle(document.querySelector("#video-container")));
|
||||
document.querySelector("#main-container").insertAdjacentHTML("beforeend", "<a id='hide-playlist' class='hide-on-small-only hide-playlist-button' href='#!'><i class='material-icons'>keyboard_arrow_right</i></div>");
|
||||
document.querySelector("#hide-playlist").style.left = (document.querySelector("#video-container").offsetWidth - document.querySelector("#hide-playlist").offsetWidth) + "px";
|
||||
}
|
||||
|
||||
@@ -210,21 +210,54 @@ window.addEventListener("DOMContentLoaded", function() {
|
||||
Frontpage.init();
|
||||
}
|
||||
if(window.location.pathname == "/" && !client) {
|
||||
if(document.querySelectorAll("script[src='https://www.youtube.com/iframe_api']").length == 1){
|
||||
try{
|
||||
Player.onYouTubeIframeAPIReady();
|
||||
//SC.Widget(Player.soundcloud_player).bind("ready", Player.soundcloudReady);
|
||||
|
||||
} catch(error){
|
||||
console.error(error);
|
||||
console.error("Seems YouTube iFrame script isn't correctly loaded. Please reload the page.");
|
||||
}
|
||||
try {
|
||||
//Player.soundcloudReady();
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
console.error("Seems SoundCloud script isn't correctly loaded. Please reload the page.");
|
||||
}
|
||||
} else {
|
||||
tag = document.createElement('script');
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
|
||||
tag.onload = function() {
|
||||
if(document.querySelectorAll("script[src='https://w.soundcloud.com/player/api.js']").length == 1) {
|
||||
|
||||
} else {
|
||||
tagSearch = document.createElement('script');
|
||||
tagSearch.setAttribute("async", true);
|
||||
tagSearch.src = "https://connect.soundcloud.com/sdk/sdk-3.3.0.js";
|
||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tagSearch, firstScriptTag);
|
||||
}
|
||||
if(document.querySelectorAll("script[src='https://connect.soundcloud.com/sdk/sdk-3.3.0.js']").length == 1) {
|
||||
console.log("exists");
|
||||
} else {
|
||||
tagSC = document.createElement('script');
|
||||
console.log("not exists");
|
||||
if (tagSC.readyState){ //IE
|
||||
tagSC.onreadystatechange = function(){
|
||||
if (tagSC.readyState == "loaded" ||
|
||||
tagSC.readyState == "complete"){
|
||||
tagSC.onreadystatechange = null;
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
}
|
||||
};
|
||||
} else { //Others
|
||||
tagSC.onload = function(){
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
};
|
||||
}
|
||||
tagSC.src = "https://connect.soundcloud.com/sdk/sdk-3.3.0.js";
|
||||
firstScriptTagSC = document.getElementsByTagName('script')[0];
|
||||
firstScriptTagSC.parentNode.insertBefore(tagSC, firstScriptTagSC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -729,6 +729,10 @@ var Player = {
|
||||
},
|
||||
|
||||
soundcloudReady: function() {
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
beginning = true;
|
||||
player_ready = true;
|
||||
if(!durationBegun) {
|
||||
@@ -969,7 +973,7 @@ var Player = {
|
||||
}
|
||||
},
|
||||
|
||||
loadPlayer: function() {
|
||||
loadPlayer: function(notify) {
|
||||
if(document.querySelectorAll("script[src='https://www.youtube.com/iframe_api']").length == 1){
|
||||
try{
|
||||
Player.onYouTubeIframeAPIReady();
|
||||
@@ -991,6 +995,29 @@ var Player = {
|
||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
}
|
||||
if(document.querySelectorAll("script[src='https://connect.soundcloud.com/sdk/sdk-3.3.0.js']").length == 1) {
|
||||
console.log("exists");
|
||||
} else {
|
||||
tagSC = document.createElement('script');
|
||||
console.log("not exists");
|
||||
if (tagSC.readyState){ //IE
|
||||
tagSC.onreadystatechange = function(){
|
||||
if (tagSC.readyState == "loaded" ||
|
||||
tagSC.readyState == "complete"){
|
||||
tagSC.onreadystatechange = null;
|
||||
Player.soundcloudReady();
|
||||
}
|
||||
};
|
||||
} else { //Others
|
||||
tagSC.onload = function(){
|
||||
Player.soundcloudReady();
|
||||
};
|
||||
}
|
||||
tagSC.src = "https://connect.soundcloud.com/sdk/sdk-3.3.0.js";
|
||||
firstScriptTagSC = document.getElementsByTagName('script')[0];
|
||||
firstScriptTagSC.parentNode.insertBefore(tagSC, firstScriptTagSC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<link rel="mask-icon" href="/assets/images/safari-pinned-tab.svg" color="#2d2d2d">
|
||||
{{/unless}}
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/{{stylesheet}}" title="Default">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/{{stylesheet}}">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" media="none" onload="if(media!='all')media='all'">
|
||||
{{#unless embed}}
|
||||
<script async type="text/javascript">
|
||||
@@ -82,9 +82,6 @@
|
||||
{{/unless}}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.0/socket.io.slim.js"></script>
|
||||
{{#unless client}}
|
||||
<script type="text/javascript" src="https://connect.soundcloud.com/sdk/sdk-3.3.0.js" async></script>
|
||||
{{/unless}}
|
||||
<script type="text/javascript" src="/assets/dist/{{javascript_file}}"></script>
|
||||
{{#unless embed}}
|
||||
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
|
||||
|
||||
Reference in New Issue
Block a user