SL360: Javascript GetPlayer() function is not defined

Aug 09, 2022

Hi, Everyone.

How to get a variable value from the storyline 360 using external javascript with GetPlayer, SetVar, and GetVar, but it doesn't work. It always gives an error like this "Uncaught ReferenceError: GetPlayer is not defined" can someone help with this?

I'm trying to get a variable value from storyline to use in frame.js (html5\data\js\frame.js) which holds the strings for defaults texts on Storyline/SCORM. Basically, I'm trying to translate texts inside the frame.js based on the user's selected language from the storyline.

Example:

  1.  A user open the course and selected the Tagalog language from the storyline.
  2. The user will submit the selected language.
  3. When the user closes the course and opens the course again this screen will be shown.
  4. But the texts on this screen will be translated based on the user's selected language in the storyline. For this one, the user selected the Tagalog language.

Please see attached files for reference.

Thank you so much!

17 Replies
OWEN HOLT

...get a variable value from the storyline 360 using external javascript with GetPlayer, SetVar, and GetVar, but it doesn't work.

Where are you running the external script? Where are you trying to show the retrieved variable information?  What exactly is the use case?

Player is an object within the Storyline published files and the Get and Set functions are associated with that object. I'm not sure you can call or trigger any of them from outside of the Storyline published environment but I'm not the JavaScript expert that others here are.

A work around might be to use JavaScript triggered by something inside of your Storyline project to retrieve your StoryLine variables send them to local storage and then, subsequently retrieve them from there.

In other words, instead of pulling values externally directly from Storyline, you push the values internally from Storyline to local and then pull the values externally from there. 

Jürgen Schoenemeyer

my first idea was waiting with "window.setTimeout", like


function updateDOM(){
var player = GetPlayer();
...
}

function waitStorylineReady(){
console.log("wait", typeof GetPlayer );

if( typeof GetPlayer === "undefined" ){
window.setTimeout( waitStorylineReady, 1000 );
} else {
updateDOM();
}
}

waitStorylineReady();

but this doesn't work

storyline needs the function "window.globalProvideData( ... )" to start

you have moved the function to "frame-english.js", "frame-tagalog.js" (for later loading)
  -> now storyline doesn't start, "GetPlayer" is never initialize, waiting is useless

(the waiting animation is a simple css animation without javascript)

Jürgen

Math Notermans

Im afraid you made some wrong assumptions ( or im wrong, thats possible too ;-)
The texts on the Resume screen ( black screen with Resume ) is not set by variables in Storyline. As they are not yet loaded there...you cannot set those texts the way your trying. These texts are hardcoded in the player. You can change or add these texts in the player.

resume
Here you can define a language for the player. I guess its saved somewhere in xml or other Storylinedata, but for sure not in the variables...as they are not yet available when getting the resume screen.