vime
repository·main·Indexed 25 days ago
https://github.com/vime-js/vimeA customizable, extensible, and framework-agnostic media player built with web components. Vime provides a unified API for media providers like YouTube, Vimeo, and HLS. It includes a core set of web components via @vime/core and official bindings for Angular (@vime/angular), React (@vime/react), Svelte (@vime/svelte), Vue 2 (@vime/vue), and Vue 3 (@vime/vue-next).
What's inside vime
- Vime is a customizable, extensible, accessible, and framework-agnostic media player. It is built using web components, making it compatible with most modern web environments. It supports multiple media providers (HTML5, HLS, YouTube, Vimeo, etc.) and provides a unified API across different media types.
Use @vime/vue-next for Vue 3 applications
mainThe@vime/vue-nextpackage provides Vue 3 bindings for the Vime media player. These bindings wrap around the web components defined in@vime/coreand are auto-generated using Stencil. Use this package when building media player interfaces specifically for Vue 3 environments.Use @vime/svelte for Svelte applications
mainThe@vime/sveltepackage provides Svelte bindings for Vime's web components. It wraps the core functionality found in@vime/coreto provide a seamless Svelte developer experience. These bindings are auto-generated using Stencil.Use @vime/angular for Angular applications
mainThe@vime/angularpackage provides Angular bindings that wrap around the Vime web components found in@vime/core. These bindings are auto-generated by Stencil and allow you to use Vime's customizable, extensible, and accessible media player within an Angular environment.Use @vime/vue for Vue 2 applications
mainThe@vime/vuepackage provides Vue 2 bindings for Vime's web components. It wraps around the@vime/coreengine to provide a seamless integration experience within Vue 2 applications. These bindings are auto-generated using Stencil.Use @vime/react for React applications
mainThe@vime/reactpackage provides React bindings for the Vime media player. These bindings wrap around the web components defined in@vime/coreand are auto-generated using Stencil. Use this package when you want to integrate Vime's customizable, extensible, and accessible media player into a React project.Understand Vime Providers
mainProviders are responsible for loading media and controlling it (e.g., the
YouTubeprovider manages the YouTube player embed).Providers interact with the player via the
MediaProviderAdapterinterface. When player properties change (e.g.,player.currentTime = 50), the player automatically calls the corresponding provider method (e.g.,provider.setCurrentTime(50)) on the next render cycle.To prevent infinite update loops, providers emit a special
vmProviderChangeevent when the player needs to update its state, whereas all other components use thevmStateChangeevent.Build a Custom UI with Vime Components
mainInstead of using the
DefaultUi, you can build a fully custom interface by placing individual Vime UI components inside a<Ui />(or<vm-ui>) element. This allows you to mix predefined components with your own custom web components or framework components.Commonly used Vime UI components include:
ClickToPlay/<vm-click-to-play>Spinner/<vm-spinner>Poster/<vm-poster>
Example of a custom React implementation:
import React from 'react'; import { Player, Video, Ui, ClickToPlay, Spinner, Poster } from '@vime/react'; import TapSidesToSeek from './TapSidesToSeek'; function Player() { return ( <Player> <Video crossOrigin="" poster="https://files.vidstack.io/agent-327/poster.png" > <source data-src="https://files.vidstack.io/agent-327/720p.mp4" type="video/mp4" /> </Video> <Ui> <ClickToPlay /> <Spinner /> <Poster /> <TapSidesToSeek /> </Ui> </Player> ); }Install Vime for Svelte
mainYou can use Vime as raw web components via CDN, or use the
@vime/sveltebindings for typed, documented components and additional helpers.- Add themes to your HTML
<head>:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@vime/core@^5/themes/default.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@vime/core@^5/themes/light.css" />- Install the Svelte package:
npm i @vime/core @vime/svelte- Add themes to your HTML
Extend default settings in Vime
mainTo add to the existing settings (like playback rate, quality, and captions) instead of replacing them, use the
DefaultSettingscomponent. You must first disable the default settings in theDefaultUicomponent using thenoSettings(orno-settings) property to prevent duplication, then provide your ownDefaultSettingsinstance.Common properties for
DefaultSettingsincludepin(e.g.,pin="bottomRight").// React Example <DefaultUi noSettings> <DefaultSettings pin="bottomRight"> {/* Extend the default settings with new options here. */} </DefaultSettings> </DefaultUi>Run the Vime Webpack example
mainTo run the local Webpack demonstration project, clone the repository, navigate to the webpack example directory, install dependencies, and start the development server.
$: git clone https://github.com/vime-js/vime --depth=1 $: cd vime/examples/webpack $: npm install $: npm run devUse custom icon libraries in Angular with <vm-icon-library>
mainTo use a custom icon library in a Vime player within an Angular application, follow these steps:
- Set the
iconsproperty on the<vm-player>component to the name of your library (e.g.,material). - Inside
<vm-player>, add a<vm-ui>component. - Inside
<vm-ui>, use the<vm-icon-library>component to register your custom library. - Provide a
namefor your library and bind a[resolver]function to handle icon resolution.
The resolver function should accept an
iconName: stringand return the path to the icon file (e.g., an SVG URL).<!-- Set the icons property to the name of the library you'd like to use. --> <vm-player icons="material"> <!-- ... --> <vm-ui> <!-- Register a custom icon library. --> <vm-icon-library name="my-library" [resolver="customResolver" ></vm-icon-library> </vm-ui> </vm-player>class Example { customResolver = (iconName: string) => `/icons/${iconName}.svg`; }- Set the