Code Monkey home page Code Monkey logo

playerx-oembed's Introduction

PlayerX oEmbed

Uses the media platform's oEmbed API when possible and enriches the response with useful metadata / structured data from the content URL using Cloudflare workers.

The following metadata is added if possible; upload_date, duration, content_url, embed_url.

If the provider offers inline and iframe embeds like Wistia or Brightcove this API will output the inline embed code. This is most performant and gives the developer more control over video playback.

Quick Example

A consumer makes the following HTTP request:

The provider then responds with an oEmbed response:

{
  "version": "1.0",
  "type": "video",
  "provider_name": "Wistia, Inc.",
  "provider_url": "https://wistia.com",
  "title": "The World In HDR 4K",
  "duration": 115.434,
  "upload_date": "2021-11-21T23:27:19.000Z",
  "thumbnail_url": "https://embed-ssl.wistia.com/deliveries/e3479c070161f77ff5b379a17ee91c1f.jpg?image_crop_resized=960x540",
  "thumbnail_width": 960,
  "thumbnail_height": 540,
  "html": "\n<div class=\"wistia_embed wistia_async_oifkgmxnkb\" id=\"plx318\"></div>\n<script src=\"https://fast.wistia.com/assets/external/E-v1.js\"></script>\n<script>\nwindow._wq.push({\n  id: 'oifkgmxnkb',\n  options: {},\n  onReady: function(api) {\n    (api);\n  }\n});\n</script>\n",
  "width": 960,
  "height": 540,
  "player_color": "174bd2"
}

Extra End Points

/render

Provides a HTML page with only the video player embedded on it. This URL is typically used for an iframe embed.
https://api.playerx.io/render?url=https%3A%2F%2Fwesleyluyten.wistia.com%2Fmedias%2Foifkgmxnkb

/html

Returns the raw html snippet from the oEmbed response. Useful for embedding in another document. https://api.playerx.io/html?url=https%3A%2F%2Fwesleyluyten.wistia.com%2Fmedias%2Foifkgmxnkb

Consumer Request

Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).

The following query parameters are defined as part of the oEmbed spec:

param description
url Required. The URL to retrieve embedding information for.
maxwidth The maximum width of the embedded resource.
maxheight The maximum height of the embedded resource.
seo If seo=1, structured data in JSON-LD format is appended to the html property. The structured data adds SEO (Search engine optimization) to the media's embed code.
fields Filter the response properties based on the fields param. Comma separated. For example fields=title,thumbnail_url,html
api If api=1, the associated player API will be enabled via an added script. Use together with callback to set up a controllable player.
callback Set to a global JS function that can be called on the page which is passed the instance of the enabled player API. e.g. api=1&callback=console.log

These are the supported URL params in the Playerx oEmbed layer but many media platform's oEmbed API support additional URL params. For example Vimeo supports: width, height, byline, title, portrait, color, autoplay, loop, muted etc.

Purge cached resource

curl -X POST "https://api.playerx.io/oembed?url=https%3A%2F%2Fvimeo.com%2F357274789" \
-H "X-Purge: 1"

Supported Providers

Supported providers so far (feel free to open a PR):

Used by

Thanks

playerx-oembed's People

Contributors

luwes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

playerx-oembed's Issues

`/thumbnail` endpoint

Might be cool to provide on the fly resizing and be more reliable than each separate provider oembed maxwidth maxheight mechanism.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.