Is there any GetPlayer() in Html5

May 18, 2019

How can i use GetPlayer() in storyline360 as i tried to call the function in my code and it says GetPlayer() not defined.

And anyway to read builtin variables

i am using modern player for html5 output

code used in user.js:

var player=GetPlayer();
var viewed = player.GetVar(Project.SlidesViewed);
console.log(viewed)

10 Replies
Thor Melicher

Try using quotation marks to see if this fixes the problem:

var viewed = player.GetVar("Project.SlidesViewed");

Using quotation marks says to grab what it is called inside of Storyline and without quotation marks assumes it is a variable you want to pass in that you have defined in your JavaScript.

FYI - I'm using SL 3 so I'm not sure how the builtin variables are being shown now in 360 but if you can't get the variable as written try dropping the Project. to see if that works.

Hope that helps!

Paramjot Saini
Thor Melicher

Try using quotation marks to see if this fixes the problem:

var viewed = player.GetVar("Project.SlidesViewed");

Using quotation marks says to grab what it is called inside of Storyline and without quotation marks assumes it is a variable you want to pass in that you have defined in your JavaScript.

FYI - I'm using SL 3 so I'm not sure how the builtin variables are being shown now in 360 but if you can't get the variable as written try dropping the Project. to see if that works.

Hope that helps!

Hello Thor Melicher,

i am aware that quotation marks will convert the content available within to string, the problem i am referencing here is that i am not able to call getPlayer() function.

Error Detail:

user.js:2 Uncaught ReferenceError: getPlayer is not defined

i traversed around this community and found alot of solutions posted like:

1. use parent.getPlayer() instead of getPlayer(), in my case not working.

2. use timeout for few seconds, in my case not working

Paramjot Saini
Russell Killips

I don’t think project variables are accessible with JavaScript. Try creating your own variable and then assign the project variable to your created variable using a trigger. You should then be able to access your own variable using JavaScript.

i will give it a try.

Math Notermans

Allthough i dont have Storyline3, only 360 i do think there is no delay needed.
I think in the original poster code was just an error calling getPlayer instead of GetPlayer.

All Storyline internal functions have to be strictly coded as is.
This code works fine in 360 and i suppose in 3 too.

let player = GetPlayer();

let testVar = player.GetVar("test");

console.log("value: "+testVar);

Offcourse you need a custom variable called test.
If you need a project variable available in your Javascript, you use a trigger to set a custom variable to the project variables value.

Like shown here.
projectvars