Fixing issues with soundcloudplayer not understanding it is loaded

This commit is contained in:
Kasper Rynning-Tønnesen
2018-09-25 18:15:43 +02:00
parent 9d0c5173c4
commit 742ecfaa1d
3 changed files with 27 additions and 8 deletions

View File

@@ -11,6 +11,9 @@ try {
} catch(e) { } catch(e) {
_VERSION = 6; _VERSION = 6;
} }
var SC_widget;
var scUsingWidget = false;
var SC_player;
var startTime = 0; var startTime = 0;
var small = false; var small = false;
var small_player = false; var small_player = false;

View File

@@ -260,7 +260,9 @@ window.addEventListener("DOMContentLoaded", function() {
tagSC.readyState == "complete"){ tagSC.readyState == "complete"){
tagSC.onreadystatechange = null; tagSC.onreadystatechange = null;
if(sc_need_initialization) { if(sc_need_initialization) {
//Player.soundcloudReady(); if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady();
}
} else { } else {
SC_player = SC; SC_player = SC;
SC_player.initialize({ SC_player.initialize({
@@ -274,7 +276,9 @@ window.addEventListener("DOMContentLoaded", function() {
} else { //Others } else { //Others
tagSC.onload = function(){ tagSC.onload = function(){
if(sc_need_initialization) { if(sc_need_initialization) {
//Player.soundcloudReady(); if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady();
}
} else { } else {
SC_player = SC; SC_player = SC;
SC_player.initialize({ SC_player.initialize({

View File

@@ -1123,7 +1123,9 @@ var Player = {
loadSoundCloudPlayer: function() { loadSoundCloudPlayer: function() {
if(document.querySelectorAll("script[src='https://connect.soundcloud.com/sdk/sdk-3.3.0.js']").length == 1) { if(document.querySelectorAll("script[src='https://connect.soundcloud.com/sdk/sdk-3.3.0.js']").length == 1) {
try { try {
//Player.soundcloudReady(); if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady();
}
} catch(error) { } catch(error) {
sc_need_initialization = true; sc_need_initialization = true;
//console.error(error); //console.error(error);
@@ -1137,14 +1139,18 @@ var Player = {
tagSC.readyState == "complete"){ tagSC.readyState == "complete"){
tagSC.onreadystatechange = null; tagSC.onreadystatechange = null;
SC_player = SC; SC_player = SC;
//Player.soundcloudReady(); if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady();
}
Player.loadSoundCloudIframe(); Player.loadSoundCloudIframe();
} }
}; };
} else { //Others } else { //Others
tagSC.onload = function(){ tagSC.onload = function(){
SC_player = SC; SC_player = SC;
//Player.soundcloudReady(); if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady();
}
Player.loadSoundCloudIframe(); Player.loadSoundCloudIframe();
}; };
} }
@@ -1157,7 +1163,9 @@ var Player = {
loadSoundCloudIframe: function() { loadSoundCloudIframe: function() {
if(document.querySelectorAll("script[src='/assets/sclib/scapi.js']").length == 1) { if(document.querySelectorAll("script[src='/assets/sclib/scapi.js']").length == 1) {
try { try {
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady(); Player.soundcloudReady();
}
} catch(error) { } catch(error) {
//sc_need_initialization = true; //sc_need_initialization = true;
//console.error(error); //console.error(error);
@@ -1171,13 +1179,17 @@ var Player = {
tagSC.readyState == "complete"){ tagSC.readyState == "complete"){
tagSC.onreadystatechange = null; tagSC.onreadystatechange = null;
SC_widget = SC; SC_widget = SC;
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady(); Player.soundcloudReady();
} }
}
}; };
} else { //Others } else { //Others
tagSC.onload = function(){ tagSC.onload = function(){
SC_widget = SC; SC_widget = SC;
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined) {
Player.soundcloudReady(); Player.soundcloudReady();
}
}; };
} }
tagSC.src = "/assets/sclib/scapi.js"; tagSC.src = "/assets/sclib/scapi.js";