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:
- A user open the course and selected the Tagalog language from the storyline.
- The user will submit the selected language.
- When the user closes the course and opens the course again this screen will be shown.
- 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!
19 Replies
use in trigger
not
this is used in web object (= iframe)
Jürgen
This post was removed by the author
Thanks for this, but still got an error when I'm using this code:
Error: Uncaught ReferenceError: GetPlayer is not defined
Is your external javascript in a web object?
Or where is it being called from?
upload a storyline source file with your javascript code
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.
Best to share a Storyline sample of your setup...as too many open questions for any of us to help you.
Not on the web object, please see the post, it's now updated and more detailed. Thank you!
Storyline and SCORM files are now uploaded in the post, please see the post, it's now updated and more detailed. Thank you!
I could be wrong here but I do t think this will work. I suspect the player and the player variables are not loaded at this point.
Sent from my iPhone
Thanks for this. I updated the post and it's now more detailed.
Post updated and it's now more detailed. Thank you!
That's what I'm thinking as well, but still hoping that this idea will be possible :D
my first idea was waiting with "window.setTimeout", like
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
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.
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.
What i did for a similar case where the Storyline player was needed and text needed to be in the choice of the user...create multiple versions... Dutch, English, French... and on a normal page before the Storyline let the user choose the language and then the appropriate language will be started.
This makes sense thanks for this, I tried putting the GetPlayer code at the end of the function "window.globalProvideData( ... )" but still GetPlayer is not working.
Thanks for this, do you have the source files for this one? so I can check and replicate it, thanks!
I have the same problem. Any solution found yet?
Share a storyline file...then someone might be able to help.