Documentation
Saving and restoring lesson state
var player;
function icOnAppLoaded(){
player = icCreatePlayer('_icplayer');
// Write state to player before loading content
player.setState(state);
player.load('content/default.ic.xml');
}
// Read state from player
var state = player.getState();
Remarks
- State should be loaded before content.
- You can get the player state any time.
Saving and setting last visited page
On leaving lesson
function exit() {
var ps = player.getPlayerServices(), //get player services
currentPage = ps.getCurrentPageIndex(); //get current
scorm.saveLocation(currentPage); //save location
}
On loading lesson
function icOnAppLoaded(){
player = icCreatePlayer('_icplayer'); //get player
//...
var location = scorm.loadLocation(); //load location
if (location == false) {
location = '0';
}
//load player with location
player.load('content/default.ic.xml', parseInt(location));
//...
}
Exported lessons with Player
Loading the Player without loading the Lesson on startup
To start the player without starting the lesson, add the parameter "wait" to the URL with the value "yes", i.e. "?wait=yes".
Then set the state of the player:
postMessage('PLAYER_STATE:{"state":"..."})
Once we have set the state, we need to load the lesson:
postMessage('LOAD_LESSON')
This will load the lesson with the assigned state.