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 video player that is compatible with TypeScript and JavaScript for React, Vue, Angular and Svelte.

  • 3.0.0-alpha.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
increased by130%
Maintainers
1
Weekly downloads
 
Created
Source

Logo

Mirax Player

Latest npm version


Table of Contents

Description

Mirax Player is a video player that is compatible with TypeScript and JavaScript for React, Vue, Angular and Svelte. You can customize the theme color of the video player. It is robust and easy to implement, featuring readable syntax and lightweight design. It was written in pure JavaScript but can be implemented in both TypeScript and JavaScript.

React Vue.js Angular Svelte

Frameworks / LibraryTested VersionsJavaScriptTypeScript
ReactReact 18 & aboveYesYes
VueVue 3 & aboveYesYes
AngularAngular 16 & aboveNoYes
SvelteSvelte 4 & aboveYesYes

Supported scripts:

JavaScript TypeScript

Compatibility for web browsers:

Google Chrome Firefox Edge Opera


Installation

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

npm install mirax-player

Controllers

Keyboard keys / buttonsFunctionsDescriptionSupported Browsers
space barPlay & PauseThe video will play or pauseAll browsers
clickPlay & PauseThe video will play or pauseAll browsers
alt+p or cmd+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
swipe for time frameProgress barTo adjust video frame timestampAll browsers

Usage

Mirax Player version 3 has major changes:


  • You can now declare value of colors inside to your component app.

  • Adding miraxErrorHandler in separate function.

SourcesUsageThemesReactVueAngularSvelte
Local or hosted video FileVideo PlayerYesTestedTestedNot yetNot yet

"Reminder: This is an alpha test."


"Soon, it will also be available in Angular, and Svelte."


syntax for importing Mirax Player :


// Importing syntax for React, Vue, Angular, and Svelte:

import { miraxplayer, miraxErrorHandler } from 'mirax-player';



Once you finish set-up the code examples below you need to restart your server like:

npm run dev
npx ng serve

React

You need to use "useRef" in React hooks:



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

const ExampleComponent = () => {
  const videoRef = useRef(null);
  const playerTheme = "rgba(250, 149, 35, 0.9)"; // change color here (you can use rgba or rgb or hexa or colorname)
  const progressTheme = "blue"; // change color here (you can use rgba or rgb or hexa or colorname)

  useEffect(() => {
    if (videoRef.current) {
      miraxplayer(videoRef.current, playerTheme, progressTheme);
      miraxErrorHandler(videoRef.current); 
    }
  }, []);

  return (
    <div className="whatever">
      <video ref={videoRef} className="mirax-player" src="clip.mp4"></video>
    </div>
  );
};

export default ExampleComponent;

Typescript: React


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

interface Props {}

const ExampleComponent: React.FC<Props> = () => {
  const videoRef = useRef<HTMLVideoElement>(null);
  const playerTheme = "rgba(250, 149, 35, 0.9)"; // change color here (you can use rgba or rgb or hexa or colorname)
  const progressTheme = "blue"; // change color here (you can use rgba or rgb or hexa or colorname)

  useEffect(() => {
    if (videoRef.current) {
      miraxplayer(videoRef.current, playerTheme, progressTheme);
      miraxErrorHandler(videoRef.current); 
    }
  }, []);

  return (
    <div className="whatever">
      <video ref={videoRef} className="mirax-player" src="clip.mp4"></video>
    </div>
  );
};

export default ExampleComponent;

Vue


You need to use ref in Vue attributes:


<template>
  <div class="whatever">
    <video ref="videoRef" class="mirax-player" src="clip.mp4"></video>
  </div>
</template>

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

export default {
  setup() {
    const videoRef = ref(null);
    const playerTheme = "none"; // change color here (you can use rgba or rgb or hexa or colorname)
    const progressTheme = "orange"; // change color here (you can use rgba or rgb or hexa or colorname)

    onMounted(() => {
      if (videoRef.value) {
        miraxplayer(videoRef.value, playerTheme, progressTheme);
        miraxErrorHandler(videoRef.value);
      }
    });

    return {
      videoRef
    };
  }
};
</script>



Typescript: Vue


<template>
  <div class="whatever">
    <video ref="videoRef" class="mirax-player" src="clip.mp4"></video>
  </div>
</template>

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

export default {
    name: 'ExampleComponent',
  setup() {
    const videoRef = ref<HTMLVideoElement>(null);
    const playerTheme = "none"; // change color here (you can use rgba or rgb or hexa or colorname)
    const progressTheme = "orange"; // change color here (you can use rgba or rgb or hexa or colorname)

    onMounted(() => {
      if (videoRef.value) {
        miraxplayer(videoRef.value, playerTheme, progressTheme);
        miraxErrorHandler(videoRef.value); 
      }
    });

    return {
      videoRef
    };
  }
};
</script>



Angular


You need to use ElementRef native DOM element:

example.component.ts


import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { miraxplayer, miraxErrorHandler } from 'mirax-player';

@Component({
  selector: 'app-example',
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.css']
})

export class ExampleComponent implements OnInit {
  
  @ViewChild('video', { static: true }) video!: ElementRef<HTMLVideoElement>;
  playerTheme = "rgba(228, 41, 82, 0.3)"; // change color here (you can use rgba or rgb or hexa or colorname)
  progressTheme = "yellow"; // change color here (you can use rgba or rgb or hexa or colorname)
  ngOnInit(): void {
    this.initializeMiraxplayer();
    this.handleMiraxError();
  }
  initializeMiraxplayer() {
    if (this.video.nativeElement) {
      miraxplayer(this.video.nativeElement, this.playerTheme, this.progressTheme);
    }
  }
  handleMiraxError() {
    if (this.video.nativeElement) {
      miraxErrorHandler(this.video.nativeElement);
    }
  }

}




example.component.html


<div>
  <div class="whatever">
    <video #video class="mirax-player" src="assets/clip.mp4"></video>
  </div>
</div>

Svelte

You need to use bind:this in svelte:


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

  let video;
  const playerTheme = "none"; // change color here (you can use rgba or rgb or hexa or colorname)
  const progressTheme = "yellow"; // change color here (you can use rgba or rgb or hexa or colorname)

  // reactive statement
  $: if(video) { 
    miraxplayer(video, playerTheme, progressTheme);
    miraxErrorHandler(video); 
  }
</script>

<div>
  <div class='whatever'>
    <video bind:this={video} class="mirax-player" src="clip.mp4">
      <track kind="captions" src="" label="English" default>
    </video>
  </div>
</div>

Typescipt: Svelte


<script lang="ts">
    import { onMount } from 'svelte';
    import { miraxplayer, miraxErrorHandler } from 'mirax-player';

  let video: HTMLVideoElement | undefined;
  const playerTheme: string = "none";
  const progressTheme: string = "yellow";

  // reactive statement
  $: if(video) {
    miraxplayer(video, playerTheme, progressTheme);
    miraxErrorHandler(video); 
  }
</script>

<div>
  <div class='whatever'>
    <video bind:this={video} class="mirax-player" src="clip3.mp4">
      <track kind="captions" src="" label="English" default>
    </video>
  </div>
</div>


To customize the alignment of video:


Style

You can assign your own class name to encapsulate the video player.


.whatever {
    margin: 0 auto;
    position: relative;
    width: 100%;
}


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

To change color and theme, simply add the necessary code to your component app.


if you want pure transparent:

change into:


 const playerTheme = "none";


Features

  • Play and Pause
  • Easy to use
  • Responsiveness
  • Automatically hides the player bar
  • Capable of playing videos (Portrait or Landscape)
  • Supports 9:16 dimensions (Mobile video)
  • Fullscreen functionality
  • Adjustable volume (low or high)
  • Customizable color themes
  • Allows you to point and drag the timestamp anywhere within the video's duration
  • Supports PIP (Picture-in-Picture), allowing the clip to continue playing even if you switch to a new app while leaving the tab open.

License

MIT


Author

Demjhon Silver

Keywords

FAQs

Package last updated on 31 Aug 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