Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
fake-mediastreamtrack
Advanced tools
Readme
Fake W3C MediaStreamTrack implementation. Suitable for for Node.js or testing.
This library is intended for Node.js applications or libraries that depend on the MediaStreamTrack
class. The exposed FakeMediaStreamTrack
class does not internally manage any audio/video source.
This library provides TypeScript definitions and the FakeMediaStreamTrack
extendes the MediaStreamTrack
interface, so it can be safely used in any code requiring a MediaStreamTrack
object.
$ npm install fake-mediastreamtrack
const { FakeMediaStreamTrack } = require('fake-mediastreamtrack');
// or
import { FakeMediaStreamTrack } from 'fake-mediastreamtrack';
const track = new FakeMediaStreamTrack({ kind: 'audio' });
track.enabled = false;
console.log(
'track.readyState: %s, track.enabled: %s', track.readyState, track.enabled
);
// => 'track.readyState: live, track.enabled: false'
const clonedTrack = track.clone();
track.stop();
console.log('track.readyState: %s', track.readyState);
// => 'track.readyState: ended'
console.log('clonedTrack.readyState: %s', clonedTrack.readyState);
// => 'clonedTrack.readyState: live'
clonedTrack.applyConstraints({ frameRate: { max: 30, ideal: 20 } });
console.log('clonedTrack.getConstraints(): %o', clonedTrack.getConstraints());
// => clonedTrack.getConstraints(): { frameRate: { max: 30, ideal: 20 } }
The FakeMediaStreamTrack
class constructor accepts an object with the following fields.
const track = new FakeMediaStreamTrack({ kind, id, label, isolated, muted, data })
kind
(string, mandatory): "audio" or "video".id
(string, optional): Track unique identificator. If not given, a random one is generated.label
(string, optional): Track label. Defaults to empty string.isolated
(boolean, optional): See the spec. Defaults to false
.muted
(boolean, optional): Whether this track belongs to a muted source. Defaults to false
.data
(object, options): An object with custom application data.track.data
getter returns custom application data
object. The app can write into it at any time.track.enabled = flag
setter fires a proprietary "@enabledchange" event if the enabled
property changed.track.stop()
will fire a proprietary "@stop" event if not already stopped.track.remoteStop()
emulates a stop generated remotely. It will fired a proprietary "@stop" event and "ended" event if not already stopped.track.remoteMute()
emulates a mute generated remotely. It will fired "mute" event if not already muted.track.remoteUnmute()
emulates a unmute generated remotely. It will fired "unmute" event if not already unmuted.const { FakeMediaStreamTrack } = require('fake-mediastreamtrack');
const track = new FakeMediaStreamTrack({ kind: 'video' });
track.onended = () => console.log('track ended (1)');
track.addEventListener('ended', () => console.log('track ended (2)'));
track.addEventListener('@enabledchange', () => {
console.log('track enabled changed:', track.enabled);
});
track.enabled = false;
track.enabled = false;
track.enabled = true;
track.remoteStop();
// => track enabled changed: false
// => track enabled changed: true
// => track ended (1)
// => track ended (2)
Some W3C MediaStreamTrack properties and methods are not implemented:
track.getCapabilities()
track.getSettings()
track.onisolationchange
track.onoverconstrained
ISC
FAQs
Fake W3C MediaStreamTrack implementation
The npm package fake-mediastreamtrack receives a total of 19,041 weekly downloads. As such, fake-mediastreamtrack popularity was classified as popular.
We found that fake-mediastreamtrack demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.