@solid-primitives/devices
Version:
Primitive that enumerates media devices
55 lines (36 loc) • 1.82 kB
Markdown
<p>
<img width="100%" src="https://assets.solidjs.com/banner?type=Primitives&background=tiles&project=Devices" alt="Solid Primitives Devices">
</p>
# @solid-primitives/devices
[](https://bundlephobia.com/package/@solid-primitives/devices)
[](https://www.npmjs.com/package/@solid-primitives/devices)
[](https://github.com/solidjs-community/solid-primitives#contribution-process)
Creates a primitive to get a list of media devices (microphones, speakers, cameras). There are filtered primitives for convenience reasons.
## Installation
```
npm install @solid-primitives/devices
# or
yarn add @solid-primitives/devices
```
## How to use it
### Media Devices
```ts
const devices = createDevices();
const microphones = createMicrophones();
const speakers = createSpeakers();
const cameras = createCameras();
```
The filtered primitives are build so that they only triggered if the devices of their own kind changed.
### Device Motion
```ts
const accelerometer = createAccelerometer();
const gyroscope = createGyroscope();
```
## Demo
You may view a working example here:
https://primitives.solidjs.community/playground/devices/
## Reference
`createAccelerometer` : [devicemotion event](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicemotion_event)
`createGyroscope` : [deviceorientation event](https://developer.mozilla.org/en-US/docs/Web/API/Window/deviceorientation_event)
## Changelog
See [CHANGELOG.md](./CHANGELOG.md)