#32423 closed defect (bug) (fixed)
Media Elements Multiple Instances
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.2.2 |
Component: | Media | Keywords: | has-patch |
Focuses: | ui, javascript | Cc: |
Description
Two issues with Media Elements scripts that affect video, audio and playlist shortcodes. Although plugin works properly, the problem occurs when it comes to multiple instances :
- If a playlist shortcode is added to the page before video or audio shortcode, play button replaces the following video player instead of playlist player. Note that adding playlist after video doesn't cause an issue.
- Infinite scroll causes breaking the current video / audio shortcodes due to re-initializing the script. If script already applied to an element, it must be excluded.
Attachments (1)
Change History (7)
Note: See
TracTickets for help on using
tickets.
I wasn't able to replicate the first issue reported by @northeme, but I would like to see some improvement on the second point.
Making the core initialization method idempotent and exposing it publicly would allow it to be called by other scripts during partial page loads. Currently, scripts need to duplicate the logic and account for media elements that have already been initialized. Here's an example in Jetpack's Infinite Scroll module of the hoops that need to be jumped through.
The patch I attached exposes the initialization method at
wp.mediaelement.initialize()
and makes it idempotent to prevent nasty side-effects caused by initializing media elements more than once.