A custom imgix video element for the browser that works anywhere
npm install @imgix/ix-video
is a imgix-flavored HTML5 video element.
If you are familiar with using + Hls.js in your application, then you'll feel right at home with this web component.
If you're using npm or yarn, install that way:
```
yarn add @imgix/ix-video
or
``
npm i @imgix/ix-video
Then, import the library into your application with either import or require:
`js`
import '@imgix/ix-video';
or
`js`
require('@imgix/ix-video');
Alternatively, use the CDN hosted version of this package:
`html`
If you are using ECMAScript modules, you can also load the ix-video.mjs file with type=module:
`html`
Without if you want to use the browser built-in HTML5 video element for playback you would have to wire up Hls.js yourself.
will automatically handle recoverable errors that happen during video playback. This is particularly handy for live streams that may experience disconnects.
will use the optimal Hls.js settings for imgix Video so you don't have to worry about that. will also periodically test new versions of Hls.js and upgrade to known stable versions so you don't have to worry about upgrading to a new version of Hls.js yourself.
Loading this library in the browser will register a custom web component for .
Now you are free to use this web component in your HTML, just as you would with the HTML5
`html`
controls
muted
>
Attributes:
- start-time: number (seconds): Set this to start playback of your media at some time other than 0.
All the other attributes that you would use on a
By default will try to use native playback via the underlying
If you prefer to use the in-code MSE-based engine (currently hls.js) whenever possible, then set the prefer-playback attribute to mse.
`html`
prefer-playback="mse"
muted
controls
>
By default will try to figure out the type of media you're trying to play (for example, an HLS/m3u8 media source, an mp4, etc.) based the extension of the file from the src attribute's url. This allows to determine whether it can/should use an in-code player or native playback. By way of example, the code below has an identifiable "mp4" extension, so will rely on native plyaback via the underlying tag.
`html`
prefer-playback="mse"
controls
>
Sometimes, however, your src URL may not have an identifiable extension. In these cases, we recommend relying on the type attribute, similar to the tag's type attribute. Below is an example of explicitly declaring the MIME type for an HLS/m3u8 media source:
`html`
type="application/vnd.apple.mpegurl"
prefer-playback="mse"
controls
>
Or, for convenience, we also support the shorthand type="hls:
`html`
type="hls"
prefer-playback="mse"
controls
>
Take a look at our ix-video-react (beta) package to use in React.
No, you do not. The way imgix delivers HLS video is compliant with the HLS spec. Any video player that supports HLS will work with imgix Video.
You sure can! Pass in src=""` with an HLS url.