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 powerful free video player for React, Vue, Angular, and Svelte that can embed videos from platforms like TikTok, YouTube/Shorts, and Vimeo.

  • 4.0.0-alpha.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-96.69%
Maintainers
1
Weekly downloads
 
Created
Source

Logo

Mirax Player

Npm version Build Status Downloads License


Disclaimer: This image is based on an example TikTok embedded video clip.

Table of Contents

Description

Mirax Player is a powerful free video player for React, Vue, Angular, and Svelte that can embed videos from platforms like TikTok, YouTube/Shorts, and Vimeo. This library package enables you to set any URL once within a single embed code tag and dynamically embed videos from any video sites. It was written in pure JavaScript but can be implemented in both TypeScript and JavaScript.

React Vue.js Angular Svelte

Release-notes

  • Version 4.0.0.alpha.2

Major:

  • Adding speed control options:

  • Fullscreen will be exact mirax-player ui

  • Adding new mirax player tag:

    `mirax-player-class`
    `data-mirax-player-width`
    `data-mirax-player-float`
    `data-mirax-player-theme`
    `data-mirax-player-bar`
    
  • Adding new mirax embed tag:

    `data-mirax-fullscreen`
    `data-mirax-controls` 
    

Minor:

  • Speaker icon animation:
  • Embed parameters becomes minimal options
  • No more mirax-customizer
  • No more .whatever class name setup

Patches:

  • Progress bar minimize
  • Volume slider getting thin

Bugs Fixed:

  • When exiting fullscreen, the progress bar does not have responsive behavior.
  • Fixed the nativeElement issue in Angular 16 for video player.
  • Fixed issues in fullscreen mode for 9:16 (mobile resolution - portrait clip).

Features

  • The advantage is that this player serves as a universal tool with minimal syntax, distributed to various javascript/typescript libraries and frameworks.
  • This video player supports both TypeScript and JavaScript, making it developer-friendly.
  • Easy to use and responsive
  • Can embed videos like TikTok, YouTube, YouTube Shorts and Vimeo via Copy link
  • Capable of playing videos (Portrait or Landscape)
  • Supports 9:16 dimensions (Mobile video)
  • Fullscreen functionality
  • Customizable color themes
  • Supports PIP (Picture-in-Picture)

Installation

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

npm install mirax-player

Embed

YouTube Vimeo TikTok

SitesSource typeAdd-on ParamsLinks
YouTube / ShortsIframe Apihttps://developers.google.com/youtube/player_parametershttps://developers.google.com/youtube/iframe_api_reference
VimeoPlayer SDKhttps://developer.vimeo.com/player/sdk/embedhttps://developer.vimeo.com/player/sdk
TikTokoEmbed APIhttps://developers.tiktok.com/doc/embed-videos/https://developers.tiktok.com/doc/overview/

Thanks to these documentations of YouTube, Vimeo, and TikTok, I was able to integrate their APIs seamlessly into this library package. 😆 👏


Mirax embed tagsTypeFunctionalityTikTokYouTubeVimeo
mirax-embed-classclass nameresponsivenessrequiredrequiredrequired
data-mirax-widthattributedynamic widthn/arequiredrequired
data-mirax-heightattributedynamic heightn/arequiredrequired
data-mirax-fullscreenattributeenable fullscreenn/arequiredn/a
data-mirax-controlsattributeenable controllersn/arequiredrequired
data-mirax-embedattributevideo links to embedrequiredrequiredrequired

example:

<div className="mirax-embed-class">
  <div ref={embedVideo}
      data-mirax-width="640" // You can set any value, such as 800x450, to make it larger.
      data-mirax-height="360" //
      data-mirax-fullscreen="true" // boolean only true or false
      data-mirax-controls="true" // boolean only true or false
      data-mirax-embed="https://vimeo.com/217499569" // links from TikTok Youtube/Shorts and Vimeo
      >
  </div>
</div>

Player

Mirax player tagsTypeFunctionalityMinMaxExample value
mirax-player-classclass nameresponsivenessn/an/an/a
data-mirax-player-widthattributewidth360800640
data-mirax-player-floatattributefloat positionn/an/aleft, center, right
data-mirax-player-themeattributeplayer colorn/an/ared, green
data-mirax-player-barattributeprogress bar colorn/an/ablue, yellow

Keyboard keys / buttonsFunctionsDescriptionSupported Browsers
press space barPlay & PauseThe video will play or pauseAll browsers
clickPlay & PauseThe video will play or pauseAll browsers
press alt+pPiPPicture in Picture screen!firefox but auto appear PiP icon
click ΓPiPPicture in Picture screenAll browsers
double click the videoFullscreenIt will set as fullscreen modeAll browsers
clickFullscreenIt will set as fullscreen modeAll browsers
swipe for volumeVolumeTo adjust the volume levelAll browsers
scroll up/down speaker iconVolumeTo adjust the volume levelAll browsers
swipe for time frameProgress barTo adjust video frame timestampAll browsers
scroll up/downProgress barbackward/forwardAll browsers
press left arrow keyProgress barbackward for 10 sec.All browsers
press right arrow keyProgress barforward for 10 sec.All browsers

input:


src=" "

  • video stored location:

    public/clip.mp4 from your frameworks

    assets/clip.mp4 angular

    example.com/video/clip.mp4


React

import React, { useEffect, useRef } from "react";
import { miraxplayer } from 'mirax-player';
const ExampleComponent = () => {
  const videoPlayer = useRef(null);
  useEffect(() => {
    if (videoPlayer.current) {
      miraxplayer(videoPlayer.current);
    }
  });
  return (
    <div className="mirax-player-class">
      <video ref={videoPlayer} 
      className="mirax-player"
      data-mirax-player-width="800"
      data-mirax-player-float=" "
      data-mirax-player-theme=" "
      data-mirax-player-bar=" "
      src="clip.mp4"></video>
    </div>
  );
};
export default ExampleComponent;

Embed videos

import React, { useEffect, useRef } from "react";
import { miraxEmbed } from 'mirax-player';

const ExampleComponent = () => {
  const embedVideo = useRef(null);
  const youtubeParams = {
    playerVars: { 
      cc_load_policy: 1 
    }
  };
  const vimeoParams = { 
    responsive: true
  };
  useEffect(() => {
    miraxEmbed(embedVideo.current, youtubeParams, vimeoParams);
  });
  return (
    <div className="mirax-embed-class">
      <div ref={embedVideo}
          data-mirax-width="640"
          data-mirax-height="360"
          data-mirax-fullscreen="true"
          data-mirax-controls="true"
          data-mirax-embed="https://vimeo.com/217499569">
      </div>
    </div>
  );
};
export default ExampleComponent;

TypeScript

  • located at repository files
src/react/TypeScriptPlayer.md
src/react/TypeScriptEmbed.md

Vue

<template>
  <div class="mirax-player-class">
    <video ref="videoPlayer"
      class="mirax-player"
      data-mirax-player-width="800"
      data-mirax-player-float=" "
      data-mirax-player-theme=" "
      data-mirax-player-bar=" "
      src="clip.mp4"></video>
  </div>
</template>

<script>
import { ref, onMounted } from "vue";
import { miraxplayer } from 'mirax-player';

export default {
  setup() {
    const videoPlayer = ref(null);
    onMounted(() => {
      if (videoPlayer.value) {
        miraxplayer(videoPlayer.value);
      }
    });
    return {
      videoPlayer
    };
  }
};
</script>

Embed videos

<template>
  <div class="mirax-embed-class">
    <div ref="embedVideo"
        data-mirax-width="640"
        data-mirax-height="360"
        data-mirax-fullscreen="true"
        data-mirax-controls="true"
        data-mirax-embed="https://vimeo.com/217499569">
    </div>
  </div>
</template>

<script>
import { ref, onMounted } from "vue";
import { miraxEmbed } from 'mirax-player';

export default {
  setup() {
    const embedVideo = ref(null);
    const youtubeParams = {
      playerVars: {
        cc_load_policy: 1
      }
    };
    const vimeoParams = {
      responsive: true
    };
    onMounted(() => {
      if (embedVideo.value) {
        miraxEmbed(embedVideo.value, youtubeParams, vimeoParams);
      }
    });
    return {
      embedVideo
    };
  }
};
</script>

TypeScript

  • located at repository files
src/vue/TypeScriptPlayer.md
src/vue/TypeScriptEmbed.md

Angular



example.component.ts

import { Component, ElementRef, OnInit, 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 OnInit, AfterViewInit {
  @ViewChild('videoPlayer', { static: true }) videoPlayer!: ElementRef<HTMLVideoElement>;
  ngOnInit(): void {
  }
  ngAfterViewInit(): void {
    this.initializeMiraxplayer();
  }
  initializeMiraxplayer() {
    if (this.videoPlayer.nativeElement) {
      miraxplayer(this.videoPlayer.nativeElement);
    }
  }
}

example.component.html


<div>
  <div class="mirax-player-class">
    <video #videoPlayer
      class="mirax-player"
      data-mirax-player-width="800"
      data-mirax-player-float=" "
      data-mirax-player-theme=" "
      data-mirax-player-bar=" "
    src="assets/clip.mp4"></video>
  </div>
</div>

Embed videos

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('videoPlayer', { static: true }) videoPlayer!: ElementRef<HTMLVideoElement>;
  ngAfterViewInit(): void {
    this.initializeMiraxplayer();
  }
  initializeMiraxplayer() {
    if (this.videoPlayer.nativeElement) {
      miraxplayer(this.videoPlayer.nativeElement);
    }
  }
}

example.component.html


<div class="mirax-embed-class">
    <div #embedVideo 
      data-mirax-width="640"
      data-mirax-height="360"
      data-mirax-fullscreen="true"
      data-mirax-controls="true"
      data-mirax-embed="https://vimeo.com/217499569">
    </div>
</div>

Svelte

<script>
  import { onMount } from 'svelte';
  import { miraxplayer } from 'mirax-player';

  let videoPlayer;

  onMount(() => {
    if (videoPlayer) {
      miraxplayer(videoPlayer);
    }
  });
</script>

<div class="mirax-player-class">
  <video bind:this={videoPlayer} class="mirax-player"
      data-mirax-player-width="800"
      data-mirax-player-float=" "
      data-mirax-player-theme=" "
      data-mirax-player-bar=" "
      src="clip.mp4">
    <track kind="captions" src="" label="English" default>
  </video>
</div>

Embed videos

<script>
  import { onMount } from 'svelte';
  import { miraxEmbed } from 'mirax-player';

  let embedVideo;
  const youtubeParams = {
    playerVars: {
      cc_load_policy: 1
    }
  };
  const vimeoParams = {
    responsive: true
  };
  onMount(() => {
    miraxEmbed(embedVideo, youtubeParams, vimeoParams);
  });
</script>

<div class="mirax-embed-class">
  <div bind:this={embedVideo}
     data-mirax-width="640"
     data-mirax-height="360"
     data-mirax-fullscreen="true"
     data-mirax-controls="true"
     data-mirax-embed="https://vimeo.com/217499569"></div>
</div>

TypeScript

  • located at repository files
src/svelte/TypeScriptPlayer.md
src/svelte/TypeScriptEmbed.md

CSS-player

You can set-up attribute for position alignment of the video player.

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

Examples:

      data-mirax-player-theme="rgba(250, 149, 35, 0.9)"
      data-mirax-player-bar="rgba(17, 117, 59, 0.9)"
      data-mirax-player-theme="rgb(0,0,0)"
      data-mirax-player-bar="rgb(255, 255, 255)"
      data-mirax-player-theme="#000000"
      data-mirax-player-bar="#00ff00"
      data-mirax-player-theme="black"
      data-mirax-player-bar="red"

If you want pure transparent:

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

Colors

You have the freedom to freely set a theme color.

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

Author

Demjhon Silver

  • You can follow me on my Github account.
  • You can give some free stars for this project: ⭐
  • Thank you for your support. 😃

Keywords

FAQs

Package last updated on 13 Sep 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