Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mirax-player

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mirax-player

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.

  • 6.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
154
increased by431.03%
Maintainers
1
Weekly downloads
 
Created
Source

Logo

Mirax Player

npm version Build Status Written jest tested Downloads License


Table of Contents

Description

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 / LibrariesTested versions
React18 & above
Vue.js3 & above
Angular16 & above
Svelte3 & above

Release-notes

Version 6.1.0

Major Changes:

  • The Mirax video player has been revised.
  • The Mirax embed feature is now easier to use.
  • The Mirax player can embed multiple videos.
  • The embed TypeScript versions are available. See TypeScript

Minor Changes:

  • Examples for React embedding are based on named exports.
  • Adding a dependency from Aziwork.

Features

  • Easy to use and responsive.
  • Capable of embedding one or many videos from platforms like Facebook, TikTok, YouTube, YouTube Shorts, Twitter, Dailymotion and Vimeo.
  • Supports playing videos in both portrait and landscape orientations.
  • Set up once, everything is flexible.

Installation

To install the Mirax Player, you can use the following npm command:

npm install mirax-player

Supported-sites

Facebook Twitter YouTube TikTok Vimeo Dailymotion

Embed-video

AttributesFunctionalityTypeRequired
widthdynamic widthnumberoptional
heightdynamic heightnumberoptional
fullscreenenable fullscreenbooleanoptional
controlsenable controllersbooleanoptional
autoplayenable autoplaybooleanoptional
loopenable loopbooleanoptional
videoClassset any classnamestringyes
videoUrlvideo address, url/linksstringyes

TypeScript

TypeScript

  • located at repository files
mirax-player/
|-- src/
|   |-- angular/
|   |-- react/TypeScriptEmbed.md
|   |-- svelte/TypeScriptEmbed.md
|   |-- vue/TypeScriptEmbed.md

Embed-css

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:

  • located at css.md
mirax-player/
|-- src/css-embed/css.md (including Angular css)

If you want sample code for embed multiple videos?

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.


Google Chrome

Reminder:

  • Don't forget to restart your server.

React

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>
    </>
  );
};

Vue

<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>

Angular

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:


Angular embed 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 */
}

Svelte

<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>

Video-player

Player AttributesFunctionalityTypeRequired
player-selectorresponsivenessanyyes
data-player-widthdynamic widthintegeryes
data-player-floatdynamic alignmentstringoptional
data-player-themeplayer coloranyoptional
data-player-barprogress bar coloranyoptional

Keyboard shortcutsFunctionsDescription
press space barPlay & PauseThe video will play or pause
press alt+pPiPPicture in Picture screen
press left arrow keyrewind clipbackward for 10 sec.
press right arrow keyadvance clipforward for 10 sec.

  • location of videos stored:

    public/clip.mp4 from your frameworks

    assets/clip.mp4 -Angular

    example.com/video/clip.mp4 (url)


React video player

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>
  );
};

Vue video player

<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>

Angular video player


example.component.ts

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>

Svelte video player

<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>

CSS-player

  • Left
      data-player-float="left"
  • Center
      data-player-float="" // center is default
      //or
      data-player-float="center"
  • Right
      data-player-float="right"

Examples:

      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"

If you want pure transparent:

     data-player-theme = "rgba(0, 0, 0, 0)"

Colors

Color TypesColor syntaxExampleOpacity RangeAppearance
RGBArgba()rgba(255,0,0, 0.5)0.1 to 0.9 or 0 and 1Red half transparency
RGBrgb()rgb(255, 0, 0)noneRed
HEXA#6digits#ff0000noneRed
COLORNAMEcolornamerednoneRed

License

MIT

  • This library package is FREE for commercial or personal use. ❤️

Author

Demjhon Silver

  • Thank you for your support. 😃

Keywords

FAQs

Package last updated on 07 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc