hjalali
(Hossein Jalali)
2020 年 5 月 6 日午後 2:18
1
How can we embed reddit videos in our post? For example this post:
Link here
Has an embed code like this:
<blockquote class="reddit-card" data-card-created="1588774544"><a href="https://www.reddit.com/r/VALORANT/comments/gdyrsg/i_also_decided_to_edit_at_2am/">I also decided to edit at 2AM</a> from <a href="http://www.reddit.com/r/VALORANT">r/VALORANT</a></blockquote>
<script async src="//embed.redditmedia.com/widgets/platform.js" charset="UTF-8"></script>
pfaffman
(Jay Pfaffman)
2020 年 5 月 6 日午後 4:55
2
How about this?
https://www.reddit.com/r/VALORANT/comments/gdyrsg/i_also_decided_to_edit_at_2am/
Which does this:
18,311 votes and 465 comments so far on Reddit
Oh. That’s no good. You want the video to play in discourse, not bump you to Reddit.
「いいね!」 1
hjalali
(Hossein Jalali)
2020 年 5 月 6 日午後 5:08
3
Thanks.
Yeah we want to if possible play it right there like YouTube and Vimeo.
Falco
(Falco)
2020 年 5 月 6 日午後 5:20
4
Haha you two want that, but have you considered what Reddit wants?
Since they changed their whole philosophy and started the v.redd.it thing it is not the same anymore.
All OpenGraph and Twitter Card tags give us a static image. Reddit is pretty clear on only allowing a static image to be embedded.
If you did further, you find that the video is in a DASH container, so audio and video are separate files. Getting that to play on Discourse means, at least, using a custom JS video player.
「いいね!」 1
hjalali
(Hossein Jalali)
2020 年 5 月 6 日午後 5:23
5
Actually Reddit is allowing this:
When you press on the Embed button it provides the following:
My issue is how to allow that to display in my post in my Discourse site.
Falco
(Falco)
2020 年 5 月 6 日午後 5:26
6
I tried the old.reddit share and it’s just an image too. Is that the new reddit UI?
Falco
(Falco)
2020 年 5 月 6 日午後 5:36
8
Oh looks like they are outsourcing it to embed.ly.
Digging into it, appears that using the post ID can be used to construct a working iFrame after all.
Unless @techAPJ wants to take it, I’d say pr-welcome
<iframe src="https://old.reddit.com/mediaembed/gdyrsg" width="690" height="388">
[AN IFRAME THAT WORKS AND AUTOPLAYS THE VIDEO]
「いいね!」 2
riking
(Kane York)
2020 年 5 月 6 日午後 6:50
9
@Falco , can we figure out something that doesn’t autoplay the video?
Edit: If we forcibly apply allow="autoplay 'none'" to the iframe element in the html sanitizer, that might fix this (on new browsers only).
hjalali
(Hossein Jalali)
2020 年 5 月 6 日午後 6:53
10
Also none of the buttons on the player work (e.g. pause, full screen, etc)
Richie
(Richie Rich)
2022 年 7 月 19 日午前 9:38
11
どなたかこの件でプルリクエストを作成しませんか?
この例のURLでこちら の「共有」>「埋め込み」ボタンをクリックし、このコードをコピーすると:
<iframe id="reddit-embed"
src="https://www.redditmedia.com/r/timelapse/comments/w2al1z/amazing_timelapse_of_summertime_storms_in_florida/?ref_source=embed&ref=share&embed=true"
sandbox="allow-scripts allow-same-origin allow-popups"
style="border: none;" scrolling="no"
width="640" height="419">
</iframe>
コンポーザーウィンドウで動画が埋め込まれ、再生されます:
しかし、投稿を送信すると動画が消えてしまいます。
iframe要素の末尾にallow="autoplay 'none'"を追加すると、動画が表示され、再生(一時停止、再生など)も問題なく機能するようになります:
<iframe id="reddit-embed"
src="https://www.redditmedia.com/r/timelapse/comments/w2al1z/amazing_timelapse_of_summertime_storms_in_florida/?ref_source=embed&ref=share&embed=true"
sandbox="allow-scripts allow-same-origin allow-popups"
style="border: none;" scrolling="no"
width="640" height="419"
allow="autoplay 'none'">
</iframe>
このようになります: