https://github.com/rzcoder/mpc-hc-control
Basic api for control over MPC-HC
https://github.com/rzcoder/mpc-hc-control
Last synced: 8 months ago
JSON representation
Basic api for control over MPC-HC
- Host: GitHub
- URL: https://github.com/rzcoder/mpc-hc-control
- Owner: rzcoder
- Created: 2018-07-17T19:51:18.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-09T12:18:30.000Z (over 2 years ago)
- Last Synced: 2025-09-19T02:27:30.808Z (9 months ago)
- Language: TypeScript
- Size: 28.3 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
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
```