Opened 7 years ago

Last modified 3 years ago

#653 accepted enhancement

Add capability for embed codes to show media on other websites

Reported by: Nick Owned by:
Priority: minor Milestone:
Component: programming Keywords: embed, small
Cc: Parent Tickets:

Description

I'm looking for the ability to provide my mediagoblin users the ability to copy and paste a snippet of code - a la youtube or vimeo - to display media in another website.

Without having researched it, I'd imagine what would probably be done for video is some sort of iframe? Or alternatively, a javascript snippet with parameters that add the video.js player to the existing page and then includes the video element in its place. I could look at how other video players handle this too.

For images, it's pretty trivial once the infrastructure for configuring and displaying the embed code is in place.

Subtickets

Change History (7)

comment:1 Changed 7 years ago by Christopher Allan Webber

I think this would be fairly easy to add, actually. I imagine this working the following way:

Each media type currently provides a MEDIA_MANAGER; see mediagoblin/media_types/video/__init__.py. Add to that media type two new fields:

  • embed_func: if provided, this is a function which takes two arguments: (request, media), and returns a string of text to appear in a copy/paste embed code box.
  • embed_view: This contains a pseudo-view function that takes (request, media) as arguments and returns a response. More on this in a second.

For some media types such as images, embed_func might be enough. Embedding an image might really just be as simple as providing the text:

  <a href="/u/cwebber/m/unhappy-birthday/">
    <img href="/path/to/unhappy-birthday-med.jpg"
         alt="Unhappy birthday" />
  </a>

But for videos and audio, yes we should probably take an <iframe/> approach... so in that case those functions need to provide an embed view. Hence there should be a new view added to the MEDIA_MANAGER that would be at a url like:

  /u/some_user/m/some_media/embed/

and which has a view roughly like:

@get_user_media_entry
def media_embed(request, media):
    embed_func = media.media_manager.get('embed_func')

    if embed_func:
        return embed_func(request, media)
    else:
        return render_404(request)

I think that should probably cover the needs of this! Does that seem fairly sensible?

comment:2 Changed 6 years ago by pythonsnake

Owner: set to pythonsnake
Status: newin_progress

comment:3 Changed 6 years ago by Julien Gouesse

Hi

Why not using the video HTML5 markup with the WebM source file where it is supported and a Java applet as a fallback using JogAmp + LibAV elsewhere?
You should look at this:
https://jogamp.org/bugzilla/show_bug.cgi?id=686

Of course, I would prefer a solution without plug-in and the support of applets in OpenJDK isn't optimal (whereas Icedtea Web Start works very well).

We could use Ogg Theora and WebM with the video HTML5 markup and just display an understandable error message when the browser can't support those formats because of a lack of codec or because it is too old to support HTML5.

comment:4 Changed 6 years ago by Julien Gouesse

What is the current situation of this request for enhancement? In the meantime I use the thumbnail in some HTML code as a clickable image that leads to the GNU Mediagoblin page containing the video but:

  • the thumbnail is really small
  • it's not very explicit
  • I would prefer playing the video in the same web page

embed_func could return some code to embed the videojs player.

comment:5 Changed 5 years ago by Beanow

Like #409, I would be interested in any status updates related to embedding standards.
Has this issue had any updates?

comment:6 Changed 3 years ago by Ben Sturmfels

Owner: pythonsnake deleted
Priority: majorminor
Status: in_progressaccepted

I'm un-assigning this ticket, since it hasn't seen any progress, but would be a great feature to have.

comment:7 Changed 3 years ago by Ben Sturmfels

Keywords: small added

Marking as small-sized as Chris has scoped this fairly clearly above.

Note: See TracTickets for help on using tickets.