Forum Discussion
Is there any GetPlayer() in Html5
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
- RussellKillips-Community Member
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.
- ParamjotSainiCommunity Member
i will give it a try.
- ThorMelicher-b5Community Member
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!
- ParamjotSainiCommunity Member
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
- ParamjotSainiCommunity Member
Solution to my GetPlayer Problem:
setTimeout(function(){
var player=window.GetPlayer();
alert("hello")
}, 3000);SetTimeout is must to provide delay.
And for variable problem only user defined variable can be accessed
- ThorMelicher-b5Community Member
Very interesting that you had to create a delay to get it to work. Which LMS are you using?
- ParamjotSainiCommunity Member
i am not using any lms. i am directly publishing the content to html. using php, i am calling the story.html in iframe which hides its name.
- AndrewPiddubniaCommunity Member
have the same issues
help setTimeout, but to wait 1 second for it is confusing
Have anybody solved this issue? - DarrylPalaub492Community Member
any updates on this?
- MathNotermans-9Community Member
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 callinggetPlayerinstead ofGetPlayer.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.
Related Content
- 10 years ago
- 2 years ago
- 2 years ago