mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Better soundcloud loader
This commit is contained in:
@@ -7,6 +7,7 @@ if(domain.length > 0 && domain[0] == "client") {
|
||||
}
|
||||
var soundcloud_enabled = true;
|
||||
var local_new_channel = false;
|
||||
var sc_need_initialization = false;
|
||||
var hiddenPlaylist = false;
|
||||
var videoSource;
|
||||
var dynamicListeners = {};
|
||||
@@ -235,19 +236,27 @@ window.addEventListener("DOMContentLoaded", function() {
|
||||
if (tagSC.readyState == "loaded" ||
|
||||
tagSC.readyState == "complete"){
|
||||
tagSC.onreadystatechange = null;
|
||||
if(sc_need_initialization) {
|
||||
Player.soundcloudReady();
|
||||
} else {
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
} else { //Others
|
||||
tagSC.onload = function(){
|
||||
if(sc_need_initialization) {
|
||||
Player.soundcloudReady();
|
||||
} else {
|
||||
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];
|
||||
|
||||
@@ -729,10 +729,20 @@ var Player = {
|
||||
},
|
||||
|
||||
soundcloudReady: function() {
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
if(SC == undefined && sc_need_initialization) {
|
||||
sc_need_initialization = true;
|
||||
return;
|
||||
}
|
||||
sc_need_initialization = false;
|
||||
try {
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
} catch(e) {
|
||||
sc_need_initialization = true;
|
||||
return;
|
||||
}
|
||||
beginning = true;
|
||||
player_ready = true;
|
||||
if(!durationBegun) {
|
||||
@@ -999,8 +1009,9 @@ var Player = {
|
||||
try {
|
||||
Player.soundcloudReady();
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
console.error("Seems SoundCloud script isn't correctly loaded. Please reload the page.");
|
||||
sc_need_initialization = true;
|
||||
//console.error(error);
|
||||
//console.error("Seems SoundCloud script isn't correctly loaded. Please reload the page.");
|
||||
}
|
||||
} else {
|
||||
tagSC = document.createElement('script');
|
||||
|
||||
Reference in New Issue
Block a user