Skip to content

Commit

Permalink
refactor: rename MediaControlArgs -> MediaControlOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Dec 2, 2024
1 parent dce8f0d commit bed0044
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 36 deletions.
26 changes: 7 additions & 19 deletions packages/client-api/src/desktop/desktop-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,23 @@ export interface AudioFunction {
type: 'audio';
function: {
name: 'set_volume';
args: SetVolumeArgs;
args: {
volume: number;
deviceId?: string;
};
};
}

export interface SetVolumeArgs {
volume: number;
deviceId?: string;
}

export interface MediaFunction {
type: 'media';
function: {
name: 'play' | 'pause' | 'toggle_play_pause' | 'next' | 'previous';
args: MediaControlArgs;
args: {
sessionId?: string;
};
};
}

export interface MediaFunction {
type: 'media';
function: {
name: 'play' | 'pause' | 'toggle_play_pause' | 'next' | 'previous';
args: MediaControlArgs;
};
}

export interface MediaControlArgs {
sessionId?: string;
}

function startWidget(
configPath: string,
placement: WidgetPlacement,
Expand Down
22 changes: 11 additions & 11 deletions packages/client-api/src/providers/media/create-media-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';
import { createBaseProvider } from '../create-base-provider';
import { desktopCommands, onProviderEmit } from '~/desktop';
import type {
MediaControlArgs,
MediaControlOptions,
MediaOutput,
MediaProvider,
MediaProviderConfig,
Expand All @@ -27,48 +27,48 @@ export function createMediaProvider(
queue.output({
...result.output,
session: result.output.currentSession,
play: (args?: MediaControlArgs) => {
play: (options?: MediaControlOptions) => {
return desktopCommands.callProviderFunction(configHash, {
type: 'media',
function: {
name: 'play',
args: args ?? {},
args: options ?? {},
},
});
},
pause: (args?: MediaControlArgs) => {
pause: (options?: MediaControlOptions) => {
return desktopCommands.callProviderFunction(configHash, {
type: 'media',
function: {
name: 'pause',
args: args ?? {},
args: options ?? {},
},
});
},
togglePlayPause: (args?: MediaControlArgs) => {
togglePlayPause: (options?: MediaControlOptions) => {
return desktopCommands.callProviderFunction(configHash, {
type: 'media',
function: {
name: 'toggle_play_pause',
args: args ?? {},
args: options ?? {},
},
});
},
next: (args?: MediaControlArgs) => {
next: (options?: MediaControlOptions) => {
return desktopCommands.callProviderFunction(configHash, {
type: 'media',
function: {
name: 'next',
args: args ?? {},
args: options ?? {},
},
});
},
previous: (args?: MediaControlArgs) => {
previous: (options?: MediaControlOptions) => {
return desktopCommands.callProviderFunction(configHash, {
type: 'media',
function: {
name: 'previous',
args: args ?? {},
args: options ?? {},
},
});
},
Expand Down
12 changes: 6 additions & 6 deletions packages/client-api/src/providers/media/media-provider-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export interface MediaOutput {
session: MediaSession | null;
currentSession: MediaSession | null;
allSessions: MediaSession[];
play(args?: MediaControlArgs): void;
pause(args?: MediaControlArgs): void;
togglePlayPause(args?: MediaControlArgs): void;
next(args?: MediaControlArgs): void;
previous(args?: MediaControlArgs): void;
play(options?: MediaControlOptions): void;
pause(options?: MediaControlOptions): void;
togglePlayPause(options?: MediaControlOptions): void;
next(options?: MediaControlOptions): void;
previous(options?: MediaControlOptions): void;
}

export interface MediaControlArgs {
export interface MediaControlOptions {
sessionId?: string;
}

Expand Down

0 comments on commit bed0044

Please sign in to comment.