Closed (fixed)
Project:
Media oEmbed Control
Version:
2.0.0-beta2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Aug 2023 at 15:21 UTC
Updated:
10 Jul 2025 at 09:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
pianomansam commentedComment #5
nsciaccaThanks for this! I added a couple other parameters for YouTube when it's used as background image to suppress the controls, set the loop and a playlist param so it continues to play.
Comment #6
nsciaccaPatch attached.
Comment #7
nsciaccaFixed patch.
Comment #8
le72Applied the patch, but the background YouTube video is still not autoplay :-(
Using Drupal core 10.2.3 with Media oEmbed Control 2.0.0-beta3.
Comment #9
le72The problem is in HTML::load(), HTML::saveHTML().
The "allowfullscreen" attribute becomes allowfullscreen="" and farther replacement doesn't work.
Comment #10
ipitbiz commentedI've added a small change to make the patch work, although I'd like to have it reviewed in case anyone has a better solution.
Comment #11
phjouThe patch works for me, the video is playing automatically now. Thank you!
EDIT: Actually, it depends on the video, if there is any special character like quote in the video, then it does not work.
It is due to the replacement.>
For example using this video: https://www.youtube.com/watch?v=UKcWushnRpQ
In the old tag, it will be:
title="Amir - États d'amour (Clip officiel)"In the new tag, it will be:
title="Amir - États d'amour (Clip officiel)"So the replacement doesn't work and the autoplay will not apply. I had a hard time to find the reason, I was becoming crazy. So happy I found the origin of the issue.
I'm working on a patch, coming soon...
Comment #12
phjouOk changes pushed to the merge request branch.
EDIT: I am not sure what's going on with the dev branch 2.x but impossible to pull it through composer.
Comment #13
phjouOk I pushed a new change reverting the encoding to use a single replace instead. It seems some characters like & are already & but the apostrophe is not. So the previous change broke videos with other special characters.
If we were directly using $dom->saveHTML then the issue would not even occur but since it creates problems with the css placeholders we cannot get rid of the str_replace approach and use saveHTML.
So I went down the road to use another replace to handle that case. The code for the apostrophe is not even ' but ' which I find strange as well.
The str_replace approach might have unexpected issues that we are not aware of, but so far the branch worked very well in that version and I could get all videos that I tested in autoplay.
Comment #15
igoragatti commentedI've reduced the str_replace to change only the src address, since that is the only thing we are changing on the markup I thought it would be cleaner that way
Comment #16
michaelmol commentedI can confirm that the https://www.drupal.org/project/media_oembed_control/issues/3380731#comme... works for youtube videos to support autoplaying.
so please merge the https://git.drupalcode.org/project/media_oembed_control/-/merge_requests...
Comment #18
jacobbell84 commentedThank you!