Skip to content

Easy Media: Simplified Library to Play and Record Sounds with ZeppOS

Notifications You must be signed in to change notification settings

juanitadion/zeppos-easy-media

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Sound Player and Recorder Library for ZeppOS

This library provides two classes, SoundPlayer and SoundRecorder, for playing and recording sounds respectively. It wrapps over the official approach, is more user-friendly and introduces an extra feature that allows for the cancellation of any ongoing sound playback.

SoundPlayer

The SoundPlayer class allows you to play sound files. Here's an example of how to use it:

import { SoundPlayer } from 'easy-media.js';

// create a new SoundPlayer that stops when changing files
const player = new SoundPlayer("my-sound.mp3", true); // stop_on_play = true
player.play();  // plays the first file

// in case later you have to change the file
player.changeFile('path-to-another-audio-file');  // stops the first file and prepares the second one

Methods

play():

Starts playing the sound. If the sound is already playing, it stops and prepares the sound again.

stop():

Stops the sound. If the sound is playing, it stops the sound and releases the player.

changeFile(filename):

Changes the sound file to play.

destroy():

Destroys the player. If the sound is playing, it stops the sound and removes event listeners.

SoundRecorder

The SoundRecorder class allows you to record sounds. Here’s an example of how to use it:

import { SoundRecorder } from 'easy-media.js';

const recorder = new SoundRecorder('mic-recording.opus');
recorder.start();

Methods

start():

Starts recording.

stop():

Stops recording.

changeFile(target_file):

Changes the target file for the recording.

About

Easy Media: Simplified Library to Play and Record Sounds with ZeppOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%