You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This plugin brings Mux Video to Payload! It creates a “Videos” collection within the admin panel, making it simple to upload videos directly to Mux and manage them.
Features include:
Support for both public and signed playback policies.
Ensures that videos deleted in the admin panel are automatically deleted from Mux, and vice versa.
Video gif previews on the videos collection list view, which can be disabled if required.
Payload Setup
There are two possible setups for this plugin: The public setup, and the signed URLs setup. The main difference between the two is that the signed URLs setup requires setting up a little extra configuration, but that's about it.
To get started, you’ll need to generate your MUX tokens and secrets from the MUX Dashboard. When configuring the webhook, set the URL to the automatically generated API endpoint provided by this plugin at /api/mux/webhook. If you have set a custom API route in Payload config via routes.api, the API endpoint will be <your_custom_api_route>/mux/webhook.
An optional function to determine who can upload files. Should return a boolean or a Promise resolving to a boolean.
signedUrlOptions
MuxVideoSignedUrlOptions
Optional
Options for signed URL generation.
posterExtension
'webp' | 'jpg' | 'png'
"png"
The image format to use for video posters.
animatedGifExtension
'gif' | 'webp'
"gif"
The image format to use for animated preview thumbnails.
adminThumbnail
'gif' | 'image' | 'none'
"gif"
Specifies the type of thumbnail to display for videos in the collection list view.
autoCreateOnWebhook
boolean
false
If enabled, the Mux webhook will automatically create videos that are missing in Payload when webhooks are received from Mux. Useful for uploading videos directly in Mux and automatically backfilling them in Payload.
initSettings Options
Option
Type
Default
Description
tokenId
string
Required
The Mux token ID.
tokenSecret
string
Required
The Mux token secret.
webhookSecret
string
Required
The secret used to validate Mux webhooks.
jwtSigningKey
string
Optional
Optional JWT signing key, required for signed URL setup.
jwtPrivateKey
string
Optional
Optional JWT private key, required for signed URL setup.
uploadSettings Options
Option
Type
Default
Description
cors_origin
string
Required
The required CORS origin for Mux.
new_asset_settings
MuxVideoNewAssetSettings
Optional
Additional settings for creating assets in Mux.
new_asset_settings Options
Option
Type
Default
Description
playback_policy
`Array<'public'
'signed'>`
public
signedUrlOptions Options
Option
Type
Default
Description
expiration
string
"1d"
Expiration time for signed URLs. Default is "1d".
Videos Collection
This is the collection generated by the plugin with the mux-video slug.
Field
Type
Read-Only
Description
title
text
No
A unique title for this video that will help you identify it later.
assetId
text
Yes
duration
number
Yes
posterTimestamp
number
No
A timestamp (in seconds) from the video to be used as the poster image. When unset, defaults to the middle of the video.
aspectRatio
text
Yes
maxWidth
number
Yes
maxHeight
number
Yes
playbackOptions
array
Yes
playbackOptions Fields
Field
Type
Read-Only
Description
playbackId
text
Yes
playbackPolicy
select
Yes
Options: signed, public
playbackUrl
text (virtual)
Yes
posterUrl
text (virtual)
Yes
Payload Usage Example
import{CollectionConfig}from'payload'exportconstExampleCollection: CollectionConfig={slug: 'example',fields: [// To link videos to other collection, use the `relationship` field type{name: 'video',label: 'Preview Video',type: 'relationship',relationTo: 'mux-video',},],}
Frontend Usage Example
importconfigfrom'@/payload.config'import{getPayload}from'payload'importMuxPlayerfrom'@mux/mux-player-react'asyncfunctionPage(){constpayload=awaitgetPayload({ config })constvideo=awaitpayload.findByID({collection: 'mux-video',id: 'example',})return(<MuxPlayer// Using playback idplaybackId={video.playbackOptions![0].playbackId!}// Or use the playback URLsrc={video.playbackOptions![0].playbackUrl!}// Posterposter={video.playbackOptions![0].posterUrl!}/>)}exportdefaultPage
Credits
Huge shoutout to jamesvclements for building the initial version of this plugin!