v2.0.0
sampotts/plyrv2.0.0Aug 22, 2016by sampotts
AI Summary
A major version release introducing significant architectural changes to how instances are stored, accessed, and managed.
Key Highlights
- Reverted `setup()` behavior to return the instance directly.
- Instances are now stored on the media element itself rather than the container.
- Added a new `get()` method and several API methods (`getOriginal`, `getContainer`, `getMedia`, `getEmbed`, `getType`, `isReady`, `on`, `stop`).
- Players are now always wrapped in their own div, which may affect custom styling.
Breaking Changes
- `setup()` now returns the instance instead of the element.
- The reference to the plyr instance is now added to the media element rather than the original container.
- Players will always be wrapped in their own div now, which may break custom styling based on DOM position.
New Features
- New `get()` method on the global plyr object to get all instances inside a container.
- New API methods: `getOriginal`, `getContainer`, `getMedia`, `getEmbed`, `getType`, `isReady`, `on`, `stop`.
- New `destroyed` event when `destroy()` has completed.
- Default volume is now 10 (max) rather than 5.
- Sprite is only loaded once.
Full Release Notes
This version contains several potential **_breaking changes**_: - `setup()` has been reverted to pre v1.8.0 behaviour; meaning it will return the _instance_ rather than the _element_. This is because the reference to the instance is no longer added to the original element (see below). - The reference to the `plyr` instance is now added to the media element rather than original container. This is because if a container with multiple children was passed to `setup()` the references to all instances would have been added to the container, creating issues. I would recommend using the return value from `setup()` or the new `get()` method to access the instance. - Players will always be wrapped in their own div now - this makes `setup()` and `destroy()` cleaner. This _may_ break any custom styling based on DOM position. - Players no longer seek to 0 on 'ended' - this is to fix a bug with Microsoft Edge as it triggers 'ended' on media change for whatever reason. They'll never change ;-) And some other changes and bug fixes: - New `get()` method on the global plyr object to get all instances inside a container - New API methods: - `getOriginal()` to get the original, _unmodified_ element plyr was setup on (`<video>`, `<audio>` or empty `<div>` for YouTube and Vimeo) - `getContainer()` to get the players outer wrapper element - `getMedia()` to get the players media element (`<video>`, `<audio>` or empty `<div>` for YouTube and Vimeo) - `getEmbed()` to access the YouTube or Vimeo API directly - `getType()` to get the type of the player - `isReady()` to determine if an instance has completed setup and necessary APIs are loaded (for YouTube / Vimeo) - `on()` to provide an easy way to listen to events - `stop()` to, you guessed it, stop the player - `destroy()` now works correctly for YouTube and Vimeo (fixes #272) - New `destroyed` event when `destroy()` has completed (original element is passed as event.target) - Default volume is now 10 (max) rather than 5 - Sprite is only loaded once (fixes #259) - Fixes for Vimeo post message bugs on source change or destroy (fixes #318) - Save caption state in storage (fixes #311) - Added keyboard shortcuts to the current focused player (with `keyboardShortcuts` boolean option to disable) (fixes #309) - Fix for captions bug (fixes #332) - Change to AMD (fixes #298)