Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#32423 closed defect (bug) (fixed)

Media Elements Multiple Instances

Reported by: northeme's profile northeme Owned by: wonderboymusic's profile wonderboymusic
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)

32423.diff (2.5 KB) - added by bradyvercher 9 years ago.

Download all attachments as: .zip

Change History (7)

@bradyvercher
9 years ago

#1 @bradyvercher
9 years ago

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.

#2 @joedolson
9 years ago

  • Focuses accessibility removed

#3 @bradyvercher
9 years ago

  • Keywords has-patch added

#4 @wonderboymusic
9 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Owner set to wonderboymusic
  • Status changed from new to assigned

#5 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34346:

MediaElement, update wp-mediaelement.js:

  • create a public initialize method on the wp.mediaelement namespace
  • make it idempotent to prevent nasty side-effects caused by initializing media elements more than once

Props bradyvercher.
Fixes #32423.

#6 @Fab1en
9 years ago

#34152 was marked as a duplicate.

Note: See TracTickets for help on using tickets.