P11MediaPlayerNative Component
The
P11MediaPlayerNative component provides a unified wrapper for native HTML <video> and <audio> elements. It allows developers to embed media content with essential controls and playback options, relying purely on native browser capabilities and custom CSS for styling.
Note: This component always renders with native browser controls enabled. Be aware that browser policies often restrict autoplay for unmuted media.
Component API
| Parameter | Type | Default | Description |
|---|---|---|---|
MediaType Required |
MediaType |
- | Gets or sets the type of media to play (Video or Audio). |
Sources |
List<MediaSource> |
new List<MediaSource>() |
Gets or sets the sources for the media element. Use this for multiple formats for broader browser compatibility. This list takes precedence over the single Src parameter. |
Src |
string? |
null |
Gets or sets the default source for a single media file. Ignored if the Sources list is populated. |
Autoplay |
bool |
false |
Gets or sets a value indicating whether the media should start playing automatically. Beware: Browsers often block autoplay unless muted. |
Loop |
bool |
false |
Gets or sets a value indicating whether the media should loop. |
Muted |
bool |
false |
Gets or sets a value indicating whether the media should be muted by default. |
Preload |
PreloadOption |
PreloadOption.Auto |
Gets or sets how the media should be preloaded by the browser. |
AdditionalAttributes |
Dictionary<string, object>? |
null |
Captures all unmatched attributes to pass directly to the underlying media element. Example: P11MediaPlayerNative class="my-video" poster="image.jpg" |