Problem/Motivation

YouTube video is keep playing after closing the modal containing it.

Steps to reproduce

Add a YouTube video to a modal. Start the video and close the modal. The video keeps playing and can't be stopped at this point.

Proposed resolution

The module's js should stop the video on modal close event.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork modal_page-3559547

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

keszthelyi created an issue. See original summary.

renatog’s picture

Nice catch

renatog’s picture

I didn't spend so much time investigating yet, however I think there is no solution lol

I mean; the video runs inside of an iFrame
On this iFrame is an external website (youtube.com)
When the Modal is closed, our JS on Drupal won't be able to trigger the "stop button" inside of external site that runs inside of iFrame
Since it's a "separated website"

Just a guess for now, I didn't studied more about that yet, but if someone has ideas or suggestions, feel free to share here and we can read better

dhruv.mittal’s picture

Assigned: Unassigned » dhruv.mittal

Working on it

renatog’s picture

Awesome!

Thank you so much @dhruvmittal

dhruv.mittal’s picture

Assigned: dhruv.mittal » Unassigned
Status: Active » Needs review
StatusFileSize
new2.71 MB

I'm happy to help @renatog
Please review !!

renatog’s picture

Nice catch to rest the src to stop the video inside of iFrame
:D
Thanks a lot

renatog’s picture

Status: Needs review » Needs work
dhruv.mittal’s picture

Assigned: Unassigned » dhruv.mittal

On it

dhruv.mittal’s picture

Assigned: dhruv.mittal » Unassigned
Status: Needs work » Needs review

@renatog thanks for your feedback. I've now removed the redundant code and created a separate file for handling the issue.
Please review and let me know if any assistance required further.
Thank you

renatog’s picture

It was amazing!!

Drupal.modalPage.stopYouTubeVideos($(this));

I'll test here, thanks a lot @dhruvmittal

renatog’s picture

Status: Needs review » Reviewed & tested by the community

Tested on 6.0.x and worked fine after running cache rebuild

  • 3a8ea724 committed on 6.0.x
    feat: #3559547 YouTube video keeps playing after closing modal
    
    By:...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Moved to the dev branch

Thank you so much, team

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

renatog’s picture

Really appreciated!

Released at: https://www.drupal.org/project/modal_page/releases/6.0.0-beta11

Btw, I think we can move this fix to 5.1.x as well

dhruv.mittal’s picture

Hello @renatog thank you very much for the appreciation.
But I think You forgot to assign credits.

renatog’s picture

@dhruv.mittal thanks for letting me know

Credits has been applied

renatog’s picture

Reported a separated ticket to apply this same solution at version 5.1.x:

#3570102: [5.1.x] YouTube video keeps playing after closing modal

dhruv.mittal’s picture

Thanks @renatog
I'll love to work on the provided issue too

renatog’s picture

Awesome, thanks a lot!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.