Twitter (and Dailymotion) video onebox autoplays without user interaction

When a video from twitter is oneboxed, it seems to auto-play without any user interaction. This is quite obnoxious. For example

https://twitter.com/UniofNottingham/status/827966230568988672/video/1

6 Likes

I am having a similar issue with videos, but can’t say whether it’s restricted to Twitter or not.

The below thread has an embedded video in the 15th post, but it plays whether you like it or not.

http://forum.singletrackbc.com/t/ama-supercoss-2017/345

1 Like

Your example looks like a Dailymotion video, so this isn’t just restricted to Twitter.

I’m not really sure what the solution is here, as Discourse doesn’t have any control of what is inside an iframe… :frowning:

It’s annoying as hell.

It is not autoplaying on my iPad right now, so this isn’t a valid statement.

1 Like

@ron_jeremy, @david, what browser/device are you using? I’m on Windows 10, Chrome, and am seeing the video autoplay. However, opening this topic on my phone (Android 7.1.1m Chrome) is didn’t…

Lubuntu 16.10
Firefox
Chrome

MacOS Sierra
Chrome
Safari

The thread I linked to will have DailyMotion videos embedded every week throughout the Supercross season, meaning in a month or two there will be 20 auto-playing videos to greet vieweres of the thread.

Update
I just tested this on my Nexus 6P running Chrome on Android 7.1.1 and the issue does not happen. It seems to be a desktop issue across multiple browsers and operating systems.

1 Like

Remember flash is about to become click to play by default on all browsers. Which it should have been, for years…

1 Like

Running Chrome on Windows 10, the video above does autoplay, and does not appear to be a flash player.

3 Likes

Sure @zogstrip can have a look.

3 Likes

Any update on this? I am also getting end-user complaints. Twitter videos to be more specific.

I have not yet investigated thoroughly, but it might be that Chrome’s behaviour has changed recently:

https://productforums.google.com/forum/m/#!topic/chrome/2c2JsQFohoo

The reason this isn’t an issue on iPad/Android is because those browsers will not allow a video element with sound to play without user interaction. Desktop browsers do not have this restriction.

These articles have information on when videos can autoplay on iOS/Android:

Muted Autoplay on Mobile: Say Goodbye to Canvas Hacks and Animated GIFs!

I think this is a change from Twitter/Dailymotion rather than a browser thing (i.e. they’ve set the autoplay attribute on the video elements inside the iframes)

Using the example in my first post, the link I pasted has this tag in the <head>

<link rel="alternate" type="application/json+oembed" href="https://publish.twitter.com/oembed?url=https://twitter.com/UniofNottingham/status/827966230568988672" title="Uni of Nottingham on Twitter: &quot;Highlights from @LakesideArts digital show celebrating #ChineseNewYear 🐓 https://t.co/yWujAUIFNw&quot;">

which links to:

O-embed JSON
{  
   "url":"https:\/\/twitter.com\/UniofNottingham\/status\/827966230568988672",
   "author_name":"Uni of Nottingham",
   "author_url":"https:\/\/twitter.com\/UniofNottingham",
   "html":"\u003Cblockquote class=\"twitter-tweet\"\u003E\u003Cp lang=\"en\" dir=\"ltr\"\u003EHighlights from \u003Ca href=\"https:\/\/twitter.com\/LakesideArts\"\u003E@LakesideArts\u003C\/a\u003E digital show celebrating \u003Ca href=\"https:\/\/twitter.com\/hashtag\/ChineseNewYear?src=hash\"\u003E#ChineseNewYear\u003C\/a\u003E \uD83D\uDC13 \u003Ca href=\"https:\/\/t.co\/yWujAUIFNw\"\u003Epic.twitter.com\/yWujAUIFNw\u003C\/a\u003E\u003C\/p\u003E&mdash; Uni of Nottingham (@UniofNottingham) \u003Ca href=\"https:\/\/twitter.com\/UniofNottingham\/status\/827966230568988672\"\u003EFebruary 4, 2017\u003C\/a\u003E\u003C\/blockquote\u003E\n\u003Cscript async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"\u003E\u003C\/script\u003E",
   "width":550,
   "height":null,
   "type":"rich",
   "cache_age":"3153600000",
   "provider_name":"Twitter",
   "provider_url":"https:\/\/twitter.com",
   "version":"1.0"
}

This is a javascript based embed, which I believe Discourse ignores because it is variable height and so risks breaking scrolling :frowning:

Instead, it seems like Discourse is using the og:video property, which is a link to a page with the video autoplaying. If you visit that URL, and remove the embed_source=facebook parameter then it doesn’t autoplay any more. I suspect twitter have done this so that their videos autoplay when people share them on Facebook.

<meta property="og:video:secure_url" content="https://twitter.com/i/videos/827966230568988672?embed_source=facebook">

Note that currently a link to a twitter video does not match the custom “Twitter Status Onebox”, since the URL is not to a status, but to a video:
https://github.com/discourse/onebox/blob/master/lib/onebox/engine/twitter_status_onebox.rb#L8

So I think the only way this can be solved on the Discourse end is by implementing a “Twitter video” onebox which takes the og:video URL and removes the embed_source=facebook parameter…

Does anyone have any tidier ideas?

2 Likes

Came here to report the same issue with Dailymotion videos. Is there a way to disable video embedding of a specific platform until this issue get fixed?

The “onebox domains blacklist” setting in the admin panel could be used to disable oneboxing for dailymotion. You’ll need to add “www.dailymotion.com”.

Note that any existing posts with oneboxes will need to be “rebaked” for this to take effect - easiest way to do this is to click the wrench below a post and click “rebuild HTML”

Also, onebox does a lot of caching, so it may take a bit of time for the blacklist to take effect :slight_smile:

5 Likes

I’ve just submitted 2 PRs, one to discourse/onebox and one to discourse/discourse. These together should hopefully fix all the twitter-related issues in this thread.

https://github.com/discourse/onebox/pull/347

https://github.com/discourse/discourse/pull/4766

5 Likes

And while I’m at it, here’s a PR to stop autoplay on dailymotion

https://github.com/discourse/onebox/pull/348

5 Likes

This is still a problem?

Yes it is, still waiting on the Pull requests to be merged in

3 Likes

It’s also an issue when a direct URL to a video is turned into an HTML video, it autoplays.

Hmm… I’m not sure why that would be the case - the basic video onebox doesn’t add the autoplay attribute as far as I can see

https://github.com/discourse/onebox/blob/master/lib/onebox/engine/video_onebox.rb#L15

Please can you post an example here on meta?

2 Likes