Blazorise Video component
Play local files or streaming media with the Video component.
To use the Video component, install the Blazorise.Video package first.
The extension uses Video.js v10 for browser playback. Its JavaScript, styles, streaming integrations, and skin assets are served from the package and loaded on demand, so normal usage does not require CDN references.
Structure
| Type | Purpose |
|---|---|
Video |
Hosts the player, coordinates playback state, and exposes controls, events, streaming, and DRM options. |
VideoSource |
Describes the media type, title, poster, media files, and text tracks used by the player. |
VideoMedia |
Defines one media URL, MIME type, and optional dimensions. Multiple entries can represent selectable quality levels. |
VideoTrack |
Defines captions, subtitles, chapters, descriptions, or metadata associated with the media. |
Installation
NuGet
Install the Video extension package.Hide code example
Copy code
dotnet add package Blazorise.Video
Imports
Add the extension namespace to the application's main_Imports.razor.
Hide code example
Copy code
@using Blazorise.Video
Runtime assets
No service registration, script tag, stylesheet link, or CDN reference is required. Blazorise loads the locally packaged Video.js core, styles, and the media adapter required by the current source.Localization
The player follows the culture selected through the Blazorise localization service. Changing the application language updates both the Blazorise-owned labels and the locally packaged Video.js translations automatically. Set the standardlang attribute on an individual Video when that player needs a different culture.
YouTube and Vimeo hosting requirements
Pass a regular public YouTube or Vimeo page URL toSource. The component detects the provider and creates the corresponding Video.js media element. The provider video must allow embedding and the browser must be able to reach that provider.
-
A restrictive Content Security Policy must include
https://www.youtube.com,https://www.youtube-nocookie.com, andhttps://player.vimeo.cominframe-src. YouTube playback also requireshttps://www.youtube.cominscript-srcfor its IFrame Player API. - Private videos, videos whose owner disabled embedding, and provider restrictions such as age, region, or authentication requirements cannot be bypassed by the component.
- Content blockers can block the provider iframe or YouTube API even though all Blazorise and Video.js package assets are served locally.
Examples
Basic
SetSource to a browser-supported media file to create a player with the default controls.
Hide code example
Copy code
<Video Source="@("https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4")" />
YouTube
SetSource to a regular YouTube watch URL. The provider is detected automatically and its locally packaged adapter is loaded on demand.
Hide code example
Copy code
<Video Source="@("https://www.youtube.com/watch?v=M7lc1UVf-VE")" />
Vimeo
SetSource to a regular Vimeo video URL. The provider is detected automatically and its locally packaged adapter is loaded on demand.
Hide code example
Copy code
<Video Source="@("https://vimeo.com/76979871")" />
Streaming DASH
SetStreamingLibrary to StreamingLibrary.Dash when Source points to a DASH manifest.
Hide code example
Copy code
<Video Source="@("https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd")" StreamingLibrary="StreamingLibrary.Dash" />
Streaming HLS
SetStreamingLibrary to StreamingLibrary.Hls when Source points to an HLS playlist.
Hide code example
Copy code
<Video Source="@("https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8")" StreamingLibrary="StreamingLibrary.Hls" />
Widevine DRM
This example shows how to useVideo to play streams with Widevine DRM protection.
Hide code example
Copy code
<Video Source="@("https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd")" StreamingLibrary="StreamingLibrary.Dash" ProtectionType="VideoProtectionType.Widevine" ProtectionServerUrl="https://cwip-shaka-proxy.appspot.com/no_auth" />
Multiple files
Add severalVideoMedia entries to a VideoSource to offer multiple versions of the same video. Their heights become quality choices, and DefaultQuality selects the initial version.
Hide code example
Copy code
<Video Source="" DefaultQuality="720" />
@code { VideoSource videoSource = new VideoSource() { Medias = new ValueEqualityList<VideoMedia> { new VideoMedia("https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4", "video/mp4", 576), new VideoMedia("https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4", "video/mp4", 720), new VideoMedia("https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4", "video/mp4", 1080), } }; }
Best practices
-
Provide a
Posterand stableRatiowhen possible to avoid layout movement before media metadata loads. -
Add caption or subtitle
VideoTrackentries for accessible playback, and identify their language and label. - Use native media files for simple playback and select HLS or DASH only when the source is a matching streaming manifest.
- YouTube and Vimeo adapter files are served by Blazorise, but their iframe players and media require network access and permission from browser content blockers.
API
See the API reference for the parameters, events, methods, and related types available to the components covered on this page.