Mirax Player is a free video player for React, Vue, Angular, and Svelte that can embed videos from platforms like Facebook, TikTok, YouTube/Shorts, Twitter, Vimeo and Dailymotion. This library package enables you to dynamically embed videos from any video site, using any URL you like, and as many videos as you need.
Frameworks / Libraries | Tested versions |
---|---|
18 & above | |
3 & above | |
16 & above | |
3 & above |
Version 6.2.0
Major Changes:
Minor Changes:
v6.2.0
v6.1.0
Patch Changes:
v6.1.2
v6.1.1
To install the Mirax Player, you can use the following npm command:
npm install mirax-player
Attributes | Functionality | Type | Required |
---|---|---|---|
width |
dynamic width | number | optional |
height |
dynamic height | number | optional |
fullscreen |
enable fullscreen | boolean | optional |
controls |
enable controllers | boolean | optional |
autoplay |
enable autoplay | boolean | optional |
loop |
enable loop | boolean | optional |
videoClass |
set any classname | string | yes |
videoUrl |
video address, url/links | string | yes |
mirax-player/
|-- src/
| |-- angular/
| |-- react/TypeScriptEmbed.md
| |-- svelte/TypeScriptEmbed.md
| |-- vue/TypeScriptEmbed.md
You can add your own css set-up:
You may apply to app.css or index.css or any css file.
This is sample only, you can rename, recreate, and do something:
.embed-youtube-one-clip {
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
border: 2px solid orange;
width: 100%;
max-width: 640px;
margin: auto; /* Center the entire container horizontally */
}
For more css embed video styles:
mirax-player/
|-- src/css-embed/css.md (including Angular css)
Located at repository files ( EMBED MANY VIDEOS HERE)
mirax-player/
|-- src/
| |-- angular/TypeScriptEmbed.md
| |-- react/JavaScriptEmbed.md
| |-- svelte/JavaScriptEmbed.md
| |-- vue/JavaScriptEmbed.md
Use Google chrome as much as possible to load more videos properly.
Reminder:
import { useEffect } from 'react';
import { embed } from 'mirax-player';
export const ExampleComponent = () => {
useEffect(() => {
embed([
{
width: 640,
height: 360,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
])
});
return (
<>
<div className="embed-youtube-one-clip"></div>
</>
);
};
<template>
<div>
<div class="embed-youtube-one-clip"></div>
</div>
</template>
<script>
import { onMounted } from 'vue';
import { embed } from 'mirax-player';
export default {
name: 'ExampleComponent',
setup() {
onMounted(() => {
embed([
{
width: 640,
height: 360,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
])
});
return {};
},
};
</script>
import { Component, AfterViewInit } from '@angular/core';
import { embed } from 'mirax-player';
@Component({
selector: 'app-example',
template: `
<div class="embed-youtube-one-clip"></div>
`,
styleUrls: ['./example.component.css'],
})
export class ExampleComponent implements AfterViewInit {
ngAfterViewInit() {
embed([
{
width: 640,
height: 360,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
]);
}
}
For Angular css:
::ng-deep .embed-youtube-one-clip {
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
border: 2px solid orange;
width: 100%;
max-width: 640px;
margin: auto; /* Center the entire container horizontally */
}
<script>
import { onMount } from 'svelte';
import { embed } from 'mirax-player';
onMount(() => {
embed([
{
width: 640,
height: 360,
autoplay: true,
fullscreen: false,
controls: true,
videoUrl: 'https://www.youtube.com/watch?v=oEXFMGK7IC0',
videoClass: 'embed-youtube-one-clip'
}
]);
});
</script>
<div>
<div class="embed-youtube-one-clip"></div>
</div>
Player Attributes | Functionality | Type | Required |
---|---|---|---|
player-selector |
responsiveness | any | yes |
data-player-width |
dynamic width | number | yes |
data-player-float |
dynamic alignment | string | optional |
data-player-theme |
player color | any | optional |
data-player-bar |
progress bar color | any | optional |
Keyboard shortcuts | Functions | Description |
---|---|---|
press space bar |
Play & Pause | The video will play or pause |
press alt+p |
PiP | Picture in Picture screen |
press left arrow key |
rewind clip | backward for 10 sec. |
press right arrow key |
advance clip | forward for 10 sec. |
location of videos stored:
public/clip.mp4 from your frameworks
assets/clip.mp4 -Angular
example.com/video/clip.mp4 (url)
import { useEffect, useRef } from "react";
import { miraxPlayer } from 'mirax-player';
export const ExampleComponent = () => {
const playerDiv = useRef(null);
useEffect(() => {
miraxPlayer(playerDiv.current);
});
return (
<div className="player-selector">
<video className="mirax-player" ref={playerDiv}
data-player-width="800"
src="clip.mp4">
</video>
</div>
);
};
<template>
<div class="player-selector">
<video ref="playerDiv"
class="mirax-player"
data-player-width="800"
src="clip.mp4">
</video>
</div>
</template>
<script>
import { ref, onMounted } from "vue";
import { miraxPlayer } from 'mirax-player';
export default {
setup() {
const playerDiv = ref(null);
onMounted(() => {
miraxPlayer(playerDiv.value);
});
return {
playerDiv
};
}
};
</script>
import { Component, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import { miraxPlayer } from 'mirax-player';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent implements AfterViewInit {
@ViewChild('playerDiv', { static: true }) playerDiv!: ElementRef<HTMLVideoElement>;
ngAfterViewInit(): void {
this.initializemiraxPlayer();
}
initializemiraxPlayer() {
miraxPlayer(this.playerDiv.nativeElement);
}
}
example.component.html
<div class="player-selector">
<video #playerDiv
class="mirax-player"
data-player-width="800"
src="assets/clip.mp4">
</video>
</div>
<script>
import { onMount } from 'svelte';
import { miraxPlayer } from 'mirax-player';
let playerDiv;
onMount(() => {
miraxPlayer(playerDiv);
});
</script>
<div class="player-selector">
<video bind:this={playerDiv} class="mirax-player"
data-player-width="800"
src="clip.mp4">
<track kind="captions" src="" label="English" default>
</video>
</div>
data-player-float="left"
data-player-float="" // center is default
//or
data-player-float="center"
data-player-float="right"
data-player-theme="rgba(250, 149, 35, 0.9)"
data-player-bar="rgba(17, 117, 59, 0.9)"
data-player-theme="rgb(0,0,0)"
data-player-bar="rgb(255, 255, 255)"
data-player-theme="#000000"
data-player-bar="#00ff00"
data-player-theme="black"
data-player-bar="red"
data-player-theme = "rgba(0, 0, 0, 0)"
Color Types | Color syntax | Example | Opacity Range | Appearance |
---|---|---|---|---|
RGBA |
rgba() | rgba(255,0,0, 0.5) | 0.1 to 0.9 or 0 and 1 |
Red half transparency |
RGB |
rgb() | rgb(255, 0, 0) | none |
Red |
HEXA |
#6digits | #ff0000 | none |
Red |
COLORNAME |
colorname | red | none |
Red |
Demjhon Silver