mirror of
https://github.com/Boof2015/astra-mobile.git
synced 2026-08-19 12:14:47 +02:00
preliminary support for astra desktop
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { requireOptionalNativeModule, type NativeModule } from 'expo-modules-core';
|
||||
|
||||
export type AstraDesktopRemoteSessionCommand =
|
||||
| { command: 'play' }
|
||||
| { command: 'pause' }
|
||||
| { command: 'toggle-play' }
|
||||
| { command: 'previous' }
|
||||
| { command: 'next' }
|
||||
| { command: 'toggle-favorite' }
|
||||
| { command: 'seek'; position: number }
|
||||
| { command: 'stop' };
|
||||
|
||||
export interface AstraDesktopRemoteSessionState {
|
||||
title?: string | null;
|
||||
artist?: string | null;
|
||||
album?: string | null;
|
||||
desktopName?: string | null;
|
||||
artworkDataUrl?: string | null;
|
||||
playbackState: 'stopped' | 'playing' | 'paused' | 'loading';
|
||||
hasTrack: boolean;
|
||||
duration?: number | null;
|
||||
position?: number | null;
|
||||
updatedAt?: number | null;
|
||||
isFavorite?: boolean;
|
||||
}
|
||||
|
||||
type AstraDesktopRemoteSessionEvents = {
|
||||
onDesktopRemoteCommand: (event: AstraDesktopRemoteSessionCommand) => void;
|
||||
};
|
||||
|
||||
declare class AstraDesktopRemoteSessionModuleType extends NativeModule<AstraDesktopRemoteSessionEvents> {
|
||||
setNowPlaying(state: AstraDesktopRemoteSessionState): void;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
const native = requireOptionalNativeModule<AstraDesktopRemoteSessionModuleType>('AstraDesktopRemoteSession');
|
||||
|
||||
export const AstraDesktopRemoteSession = native ?? {
|
||||
addListener: () => ({ remove: () => {} }),
|
||||
removeAllListeners: () => {},
|
||||
setNowPlaying: () => {},
|
||||
clear: () => {},
|
||||
};
|
||||
Reference in New Issue
Block a user