Handle Player Methods and Promises
masterMost methods on the Player object return a Promise.
- Getters: Promises resolve with the value of the property.
- Setters: Promises resolve with the value set, or reject with an error if the operation fails.
- Exceptions: Methods like
play()andpause()may reject withPasswordErrororPrivacyErrorif the video is protected.
Note: On iOS and some mobile devices, play() cannot be triggered programmatically until the user has interacted with the player.
// Example of a setter
player.setColor('#00adef').then(function(color) {
// the color that was set
}).catch(function(error) {
// an error occurred
});
// Example of a getter
player.getLoop().then(function(loop) {
// whether or not the player is set to loop
});