# Twitter (and Dailymotion) video onebox autoplays without user interaction

**URL:** <https://meta.discourse.org/t/twitter-and-dailymotion-video-onebox-autoplays-without-user-interaction/56926>\
**Category:** Bug\
**Created:** [5 Febbraio 2017, 12:03am UTC](https://meta.discourse.org/t/twitter-and-dailymotion-video-onebox-autoplays-without-user-interaction/56926 "2017-02-05T00:03:23Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [20 Febbraio 2017, 8:15pm UTC](https://meta.discourse.org/t/twitter-and-dailymotion-video-onebox-autoplays-without-user-interaction/56926/12 "2017-02-20T20:15:36Z")

</div>

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:

> **[New Policies for iOS](https://webkit.org/blog/6784/new-video-policies-for-ios/)**
>
> Since before your sun burned hot in space and before your race was born, Safari on iOS has required a user gesture to play media in a or element.

[Muted Autoplay on Mobile - Say goodbye to canvas hacks and animated GIFs! &nbsp;|&nbsp; Blog &nbsp;|&nbsp; Chrome for Developers](https://developers.google.com/web/updates/2016/07/autoplay)

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>`

```plaintext
<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**
>
> ```plaintext
> {  
> "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 ☹

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.

```plaintext
<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/main/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?

---

_[View the full topic](https://meta.discourse.org/t/twitter-and-dailymotion-video-onebox-autoplays-without-user-interaction/56926)._
