Download the PHP package boccdotdev/polymedia without Composer

On this page you can find all versions of the php package boccdotdev/polymedia. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package polymedia

Polymedia for Craft CMS

Universal media field for Craft CMS — HLS, YouTube, Vimeo, Spotify, Mux, TikTok, MP4, audio, and 10+ more providers as first-class assets, with Media Chrome compatible player rendering.

What it's for

Polymedia stores external media URLs as lightweight .pmedia manifest files inside your existing Craft asset volumes. Each manifest is a real Asset element — searchable, relatable, permission-gated — backed by a database record holding type metadata, playback defaults, and related poster/caption/transcript assets.

The front-end renders <media-controller> + the correct provider web component via a single Twig call. No iframes, no embed codes, no JavaScript framework lock-in.

Requirements

Installation

Field Setup

Create a Polymedia field (appears in the field type picker). It extends the native Assets field, so it inherits all Craft's relation features — min/max limits, eager loading, element conditions.

Field settings:

Note: The native Assets field still works with .pmedia files for headless or advanced use cases, but loses provider filtering.

Adding Media

Click Add media URL, paste any supported URL, and give it a title. The plugin auto-detects the provider type and creates a .pmedia manifest asset. The button is available in two places:

No volume picker — the target follows your current location, falling back to the configured default volume (then the first volume you can write to) if none can be resolved.

For providers that can't be auto-detected (Shaka, Video.js, PeerTube), use the "Force Type" dropdown.

You can also set a poster image right on the Add media URL screen — image-only, with inline upload landing in the new item's folder. Posters and tracks can still be managed later on the asset edit screen.

Per-item folders

Each .pmedia is created inside its own folder (named after the title slug plus a short uid), keeping its poster and track files together and the parent volume tidy. Hard-deleting the item removes the folder and everything in it.

To reorganise items created before this behaviour existed, run:

Items already in their own folder are skipped, so it's safe to re-run.

Front-End Setup

Scripts Helper

Add to your layout template:

This emits <script type="module"> tags for Media Chrome and the providers listed in your plugin settings.

CDN Mode (default)

Zero-config. Scripts load from jsdelivr (or your configured CDN host).

Self-Host Mode

  1. Set Script Loader Mode to self-host in plugin settings.
  2. Set Self-Host Base URL (e.g. /dist/polymedia/).
  3. Copy the built provider files into that directory.

None Mode

For Vite/webpack/import-map setups — scripts() emits nothing. Wire up the imports yourself.

Twig API

craft.polymedia.player(asset, options)

Renders a full <media-controller> player:

Options: autoplay, loop, muted, controls, playsinline, preload, crossorigin, poster, class, id, attrs, children, tracks.

craft.polymedia.element(asset, options)

Renders just the media element (no controller wrapper).

craft.polymedia.data(asset)

Returns the parsed manifest data as an array.

craft.polymedia.is(asset)

Returns true if the value is a polymedia asset.

craft.polymedia.scripts(options)

Renders script tags. Options: providers (array), version (Media Chrome major), mode (cdn/self-host/none).

craft.polymedia.poster(asset)

Returns the resolved poster URL for a polymedia asset.

craft.polymedia.tracks(asset, role, siteId)

Returns track-type related assets (captions, subtitles, descriptions).

craft.polymedia.transcript(asset)

Returns the transcript related asset.

Asset Methods

Polymedia attaches a behavior to every Asset element so you can call media accessors directly on the asset — no craft.polymedia.* wrapper required. The methods mirror the Twig API one-to-one.

Twig getter shorthand also works — drop the get and the parens:

Available methods

Method Returns Equivalent
getPlayer(options = {}) Markup craft.polymedia.player(asset, options)
getElement(options = {}) Markup craft.polymedia.element(asset, options)
getData() array craft.polymedia.data(asset)
getPoster() string\|null craft.polymedia.poster(asset)
getTracks(role = 'captions', siteId = null) Asset[] craft.polymedia.tracks(asset, role, siteId)
getTranscript() Asset\|null craft.polymedia.transcript(asset)
getIsPolymedia() bool craft.polymedia.is(asset)

The behavior is attached to all assets, but the methods safely return empty values for non-polymedia assets — guard with media.isPolymedia if you mix asset kinds in the same template.

Choosing between styles

Use the asset method style for terse, asset-centric templates:

Use craft.polymedia.* when you're checking arbitrary values, in macros, or in shared partials where the input may not be an asset:

Examples by Provider

YouTube

Mux

Important: Mux uses playback-id, not src.

HLS

Spotify / Audio

Audio types use <media-controller audio> and emit a slotted <img slot="poster"> for cover artwork.

Native MP4/Audio

No additional provider scripts needed for native <video> and <audio>.

Composing Controls

Use the children option to add Media Chrome control elements:

Posters and Cover Artwork

Poster resolution order (highest priority first):

  1. Explicit poster option in Twig (false suppresses entirely)
  2. Item-level poster (attached via asset edit screen)
  3. Derived thumbnail from manifest (auto-generated for YouTube, Vimeo, Mux, Cloudflare, Wistia)

For audio types, the poster is emitted as <img slot="poster" class="polymedia-cover"> inside <media-controller audio> — available to themes that render a "now playing" cover.

Accessibility

Attach .vtt files to video items via the asset edit screen, in three roles: Captions, Subtitles, and Descriptions. Each role is a multi-select picker that can also upload straight into the item's folder. The pickers appear only on video items (audio items show the poster picker alone).

Tracks are site-scoped — attach different language files to different Craft sites. On save, each track's srclang and label are derived from the current site (primary language subtag and locale display name).

Tracks auto-emit as <track> elements inside the player. crossorigin="anonymous" is set automatically when VTT files are on a different domain.

Security

The plugin warns when saving a URL that appears to contain a signed token (e.g. Mux signed playback, S3 presigned URLs) into a publicly accessible volume. The manifest file is readable by anyone with volume access — signed tokens in public manifests may leak.

Disable the warning in plugin settings if your setup handles access control at the filesystem level.

Troubleshooting

YouTube playback error 153

YouTube refuses embedded playback (error code 153) when the embed request reaches youtube.com with no Referer header. The <youtube-video> element builds its <iframe> inside a shadow root, so this can't be fixed from your template — it's governed by your site's referrer policy, not the plugin.

Browsers default to strict-origin-when-cross-origin, which works. Error 153 means something on your site has overridden it to a stricter value such as no-referrer or same-origin, stripping the referrer to YouTube.

Fix it at the document level. Either send the header:

…or add a meta tag to your page <head>:

If you intentionally enforce a strict global policy, scope the relaxation to pages that embed YouTube rather than site-wide.

Supported Providers

Provider Element Auto-detect
HLS <hls-video> .m3u8 URLs
DASH <dash-video> .mpd URLs
Shaka <shaka-video> Manual only
Mux <mux-video> stream.mux.com
YouTube <youtube-video> youtube.com, youtu.be
Vimeo <vimeo-video> vimeo.com
Spotify <spotify-audio> open.spotify.com
TikTok <tiktok-video> tiktok.com, vm.tiktok.com
Wistia <wistia-video> *.wistia.com
JW Player <jwplayer-video> cdn.jwplayer.com
Twitch <twitch-video> twitch.tv
Cloudflare <cloudflare-video> videodelivery.net, cloudflarestream.com
PeerTube <peertube-video> Manual only
Video.js <videojs-video> Manual only
MP4/WebM/MOV <video> .mp4, .webm, .mov
Audio <audio> .mp3, .m4a, .ogg, .wav, .flac

GraphQL

GraphQL support is planned for v2. Currently Twig-only.

Roadmap

Credits

Built on Media Chrome and the media-elements monorepo by Mux.

License

MIT


All versions of polymedia with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
craftcms/cms Version ^5.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package boccdotdev/polymedia contains the following files

Loading the files please wait ...