The Mindstamp player can be controlled by your application by using window.postMessage events.
The player will listen to the following events:
- play_player
- pause_player
- rewind
- fast_forward
- change_time
- request_screenshot
- exit_fullscreen
For example, to ask the player to pause, you can use a postMessage event as follows:
document.getElementById('ms_frame').contentWindow.postMessage({event: "pause_player"}, "*")
If you would like to change the player to the 0:20 mark, you can do so like this:
document.getElementById('ms_frame').contentWindow.postMessage({event: "change_time", time: 20}, "*")
If you would like to set a variable, you can do so like this:
document.getElementById('ms_frame').contentWindow.postMessage({event: "set_variable", variable_name: "somename", variable_value: "somevalue"}, "*")
The Mindstamp player can provide a screenshot at it's current time in Base64 string format:
document.getElementById('ms_frame').contentWindow.postMessage({event: "request_screenshot"}, "*")
Note the Base64 string format means that your application will be responsible for handling the image and saving it to a file if needed.
The rewind and fast_forward events change the video time by 5 seconds if playing and 1 second if the player is paused.
Note that a video cannot be programmatically set to fullscreen due to iframe security restrictions. Only exiting fullscreen is available at this time.
Get in Touch
Need help or want to know more about JavaScript Events for Mindstamp? We're here for you! Contact [email protected] to learn more.