WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#27971 closed defect (bug) (fixed)

pauseAllPlayers in media-audiovidio.js stops players on the entire page

Reported by: raptor235 Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.9
Component: Media Keywords: has-patch
Focuses: javascript Cc:

Description

The issue is that players outside of the tinymce get stopped... the function should target the players within the tinymce editor only and don't stop all players on the page weather they're related to the switching between rich text and html mode...

$(document.body)

.on( 'click', '.wp-switch-editor', wp.media.mixin.pauseAllPlayers )


pauseAllPlayers: function() {

var p;
if ( window.mejs && window.mejs.players ) {

for ( p in window.mejs.players ) {

window.mejs.players[p].pause();

}

}

},

Attachments (2)

27971.diff (2.5 KB) - added by wonderboymusic 7 years ago.
27971.patch (973 bytes) - added by iseulde 7 years ago.

Download all attachments as: .zip

Change History (9)

#1 @wonderboymusic
7 years ago

  • Keywords reporter-feedback close added

In what case would you be editing media and want players to be continuously playing on your site? The players need to be paused because they will be removed when the context changes anyways.

Even if we were to specify the context of body as body.wp-admin or something, the editor and media modal could be loaded on the front end, and we would still want to pause the players when editing and switching contexts.

I have been trying to think of a good scenario where this would be problematic, please let me know if I am missing somehthing

#2 @raptor235
7 years ago

Hi so we run the company called Sidekick... which is a help/tutorial system within WordPress wordpress.org/plugins/sidekick ... we have an audio player that guides the user through specific scenarios so they can learn WordPress.

The player is within the body under our own div... so when we're trying to teach users about tinymce and have the users switch the tabs... our entire walkthrough experience get's stopped because all media players get stopped... even though our player on the page has nothing to do with the tinymce editor being switched to html mode... this is the scenario we're facing right now... but anyone else that might have a media or audio player playing would get stopped on the page because the tinymce editor is switching... I would suggest that only media players within the actual tinymce editor get stopped not everything on the page...

Bart

@wonderboymusic
7 years ago

#3 @wonderboymusic
7 years ago

  • Keywords has-patch added; reporter-feedback close removed
  • Milestone changed from Awaiting Review to 4.0

27971.diff fixes this by only pausing the players attached to objects. Your use case is unique, but incredibly valid.

#4 @wonderboymusic
7 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28364:

When pausing "all" players attached to MCE views, don't reach into global scope and pause "every" player. Only pause the players bound to MCE views.

Fixes #27971.

#5 @iseulde
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I don't like the click listener on .wp-switch-editor. Switching the editor can also be triggered manually with switchEditors.go(). Instead I would pause the played when the tinymce editor hides. Patch attached.

@iseulde
7 years ago

#6 @iseulde
7 years ago

I knew we'd need that editor variable at some point. ;)

#7 @wonderboymusic
7 years ago

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

In 28784:

Further adjustments after [8364], listen to an editor instance event instead of delegating a body click when attempting to pause all players belonging to a particular MCE view.

Props avryl.
Fixes #27971.

Note: See TracTickets for help on using tickets.