@@ -3,6 +3,14 @@ import { DeviceEventEmitter, NativeEventEmitter, NativeModules, Platform } from
33import { logger } from '@/lib/logging' ;
44import { audioService } from '@/services/audio.service' ;
55import { type AudioButtonEvent , useBluetoothAudioStore } from '@/stores/app/bluetooth-audio-store' ;
6+ import {
7+ createDefaultPTTSettings ,
8+ type MediaButtonPTTSettings ,
9+ type PTTMode ,
10+ } from '@/types/ptt' ;
11+
12+ // Re-export PTT types for backwards compatibility
13+ export { type MediaButtonPTTSettings , type PTTMode } ;
614
715// Lazy import to break dependency cycle with livekit-store
816const getLiveKitStore = ( ) => require ( '@/stores/app/livekit-store' ) . useLiveKitStore ;
@@ -16,37 +24,14 @@ export interface MediaButtonEvent {
1624 source ?: 'airpods' | 'bluetooth_earbuds' | 'wired_headset' | 'unknown' ;
1725}
1826
19- // PTT mode configuration
20- export type PTTMode = 'toggle' | 'push_to_talk' ;
21-
22- // Settings for media button PTT functionality
23- export interface MediaButtonPTTSettings {
24- enabled : boolean ;
25- pttMode : PTTMode ;
26- // For toggle mode: single press toggles mute state
27- // For push_to_talk mode: press to unmute, release to mute (requires double-tap for this)
28- usePlayPauseForPTT : boolean ;
29- // Double tap behavior
30- doubleTapAction : 'none' | 'toggle_mute' ;
31- doubleTapTimeoutMs : number ;
32- }
33-
34- const DEFAULT_PTT_SETTINGS : MediaButtonPTTSettings = {
35- enabled : true ,
36- pttMode : 'toggle' ,
37- usePlayPauseForPTT : true ,
38- doubleTapAction : 'toggle_mute' ,
39- doubleTapTimeoutMs : 400 ,
40- } ;
41-
4227// Try to get the native module (will be null if not installed)
4328const { MediaButtonModule } = NativeModules ;
4429
4530class MediaButtonService {
4631 private static instance : MediaButtonService ;
4732 private isInitialized = false ;
4833 private eventListeners : { remove : ( ) => void } [ ] = [ ] ;
49- private settings : MediaButtonPTTSettings = DEFAULT_PTT_SETTINGS ;
34+ private settings : MediaButtonPTTSettings = createDefaultPTTSettings ( ) ;
5035 private lastPressTimestamp : number = 0 ;
5136 private doubleTapTimer : ReturnType < typeof setTimeout > | null = null ;
5237 private pendingSingleTap : boolean = false ;
0 commit comments