capacitor-volume-buttons
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

capacitor-volume-buttons

Hardware volume buttons listener for Capacitor

Install

npm install capacitor-volume-buttons
npx cap sync

Quick example

  useEffect(() => {
    const onVolumeButtonPressed = ({ direction }: VolumeButtonPressed) => {
      if (direction === 'up') {
        console.log('Volume up pressed!');
      } else {
        console.log('Volume down pressed!');
      }
    };

    CapacitorVolumeButtons.addListener('volumeButtonPressed', onVolumeButtonPressed);

    return () => {
      CapacitorVolumeButtons.removeAllListeners();
    };
  }, []);

API

addListener('volumeButtonPressed', ...)

addListener(event: 'volumeButtonPressed', listenerFunc: VolumeButtonPressedListener) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for presses on the hardware volume buttons

Param Type
event 'volumeButtonPressed'
listenerFunc VolumeButtonPressedListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Removes all listeners for this plugin

Since: 1.0.0


Interfaces

PluginListenerHandle

Prop Type
remove () => Promise<void>

Type Aliases

VolumeButtonPressedListener

({ direction, }: VolumeButtonPressed): void

VolumeButtonPressed

{ direction: 'up' | 'down' }

Readme

Keywords

Package Sidebar

Install

npm i capacitor-volume-buttons

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

27.8 kB

Total Files

27

Last publish

Collaborators

  • clevertechfirstonsite