Skip to content

Commit

Permalink
don't restart media when it's already playing #2882
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Mar 11, 2024
1 parent a29a9c7 commit 1748a55
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions js/controllers/slidecontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,11 @@ export default class SlideContent {
isVisible = !!closest( event.target, '.present' );

if( isAttachedToDOM && isVisible ) {
event.target.currentTime = 0;
event.target.play();
// Don't restart if media is already playing
if( event.target.paused || event.target.ended ) {
event.target.currentTime = 0;
event.target.play();
}
}

event.target.removeEventListener( 'loadeddata', this.startEmbeddedMedia );
Expand Down
2 changes: 1 addition & 1 deletion js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2917,7 +2917,7 @@ export default function( revealElement, options ) {
loadSlide: slideContent.load.bind( slideContent ),
unloadSlide: slideContent.unload.bind( slideContent ),

// Media playback
// Start/stop all media inside of the current slide
startEmbeddedContent: () => slideContent.startEmbeddedContent( currentSlide ),
stopEmbeddedContent: () => slideContent.stopEmbeddedContent( currentSlide, { unloadIframes: false } ),

Expand Down

0 comments on commit 1748a55

Please sign in to comment.