Skip to content

JTCorrin/capacitor-volume-buttons

 
 

Repository files navigation

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' }

About

Hardware volume buttons listener for Capacitor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 33.4%
  • Java 28.9%
  • TypeScript 17.8%
  • Ruby 8.9%
  • Objective-C 6.5%
  • JavaScript 4.5%