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):
- api.video /oembed?url=embed.api.video/vod/vi7pA8Iz9m3S466XPu8qUJr
- Brightcove /oembed?url=players.brightcove.net/1752604059001/default_default/index.html?videoId=4883184247001
- Cloudflare /oembed?url=watch.videodelivery.net/57dbd37a90f3259b33ab5fe6f4c88e38
- Cloudinary /oembed?url=res.cloudinary.com/dkbu77yte/video/upload/sp_4k/v1640704833/the_world_in_4k_hdr
- Dailymotion /oembed?url=www.dailymotion.com/video/x85qs0t
- Facebook /oembed?url=www.facebook.com/wesleyluyten/videos/780960923305550
- JW Player /oembed?url=cdn.jwplayer.com/players/V073end4-Pd4r8gwe.html
- Mux video /oembed?url=stream.mux.com/r4rOE02cc95tbe3I00302nlrHfT023Q3IedFJW029w018KxZA.m3u8
- Streamable /oembed?url=streamable.com/pz0lmz
- Vidyard /oembed?url=share.vidyard.com/watch/SpdS7bytPcF1Ztc8d7NxHC?
- Vimeo /oembed?url=vimeo.com/648359100
- Wistia /oembed?url=wesleyluyten.wistia.com/medias/oifkgmxnkb
- YouTube /oembed?url=www.youtube.com/watch?v=uxsOYVWclA0
Used by
<plx-schema>
Add SEO to your media embeds<plx-preview>
Load lightweight previews before your media players
Thanks
- Cloudflare for the generous free tier
- noembed for the initial code structure