Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rzcoder/mpc-hc-control

Basic api for control over MPC-HC
https://github.com/rzcoder/mpc-hc-control

Last synced: 30 days ago
JSON representation

Basic api for control over MPC-HC

Awesome Lists containing this project

README

        

# MPC-HC Control

Basic control over [Media Player Classic - Home Cinema](https://mpc-hc.org/) via http api.

## Setup
Enable web interface in mpc-hc settings.

`npm i mpc-hc-control`

## Usage

```ts
const {MpcControl} = require("mpc-hc-control");

const mpcApi = new MpcControl("localhost", 13579);
mpcApi.openFile("c:\\video.mkv"));
mpcApi.setVolume(75);
```

## Methods list

Basic methods list:
```ts
/**
* @filePath - path to video file
*/
openFile(filePath: string): Promise;
```

```ts
isPlaying(): Promise
```

```ts
isPaused(): Promise
```

```ts
isStopped(): Promise
```

```ts
isMuted(): Promise
```

```ts
getVolume(): Promise
```

```ts
getPosition(): Promise

interface IPositionInfo {
duration: number;
position: number;
}
```

```ts
play(): Promise
```

```ts
pause(): Promise
```

```ts
togglePlay(): Promise
```

```ts
stop(): Promise
```

```ts
toggleFullscreen(): Promise
```

```ts
/**
* @position - new position in ms
*/
seek(position: number): Promise
```

```ts
/**
* @delta - delta from current position in ms
*/
async jump(delta: number): Promise
```

```ts
skipBack(): Promise
```

```ts
skipForward(): Promise
```

```ts
/**
* @volume - new volume in percents
*/
setVolume(volume: number): Promise
```

```ts
toggleMute(): Promise
```

```ts
nextAudioTrack(): Promise
```

```ts
prevAudioTrack(): Promise
```

```ts
nextSubtitles(): Promise
```

```ts
prevSubtitles(): Promise
```

```ts
getVariables(): Promise

interface IPlayerVariables {
version: string;

file: string;
filepath: string;
filedir: string;
size: string;

state: number;
statestring: string;

position: number;
positionstring: string;
duration: number;
durationstring: string;

volumelevel: number;
muted: boolean;
}
```

Also you can use:

```ts
/**
* @commandId - any mpc-hc supported command from commands/mpcCommands.ts
* @data - additional data provided in to api call
*/
execute(commandId: MpcCommands, data?: Dictionary): Promise
```