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

media-core

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

media-core

A Typescript code, based on MediaRecorder() API to get MediaRecorder

  • 1.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

media-core

A Typescript code, based on MediaRecorder() API to get MediaRecorder.

If you want to see complete UI react voice recording you can use this package ( React Voice Recorder )

Installation

npm i media-core

OR

yarn add media-core

Usage

Recording audio sample.

import { IMedia, MediaCore } from 'media-core';

const mediaRecorder: MediaRecorder | null = null;

const getMedia = async (): void => {

    const mediaConfig: IMedia = {
        Constraints: {
            audio: true
        },
        mediaRecorderOptions: {
            mimeType: 'audio/webm'
        }
    }

    try {
        mediaRecorder = await MediaCore(mediaConfig);
    } catch (e) {
        // catch error
    }

}

Fucntion and Interface

MediaCore

This function return MediaRecorder, you must pass config that use IMedia Interface, if this function can not return MediaRecorder instance it throw an error.

interface IErrorMessage {
    id: number
    message: string
}

For error id I use enum and I exported it.

enum ErrorEnum {
    Security,
    RejectPermission,
    TypeSupport
}

MediaCoreConfig

You must pass this config to the MediaCore.

interface IMedia {
    Constraints: {
        audio?: boolean,
        video?: boolean
    },
    mediaRecorderOptions?: {
        mimeType: string
        audioBitsPerSecond?: number,
        videoBitsPerSecond?: number
        bitsPerSecond?: number,
    }
}

Contributing

Feel free to submit a PR if you found a bug (I might've missed many! 😀) or if you want to enhance it further.

Thanks!. Happy Recording!

Keywords

FAQs

Package last updated on 10 Oct 2022

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