MPC-HC Control
Basic control over Media Player Classic - Home Cinema via http api.
Setup
Enable web interface in mpc-hc settings.
npm i mpc-hc-control
Usage
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:
openFile(filePath: string): Promise<any>;
isPlaying(): Promise<boolean>
isPaused(): Promise<boolean>
isStopped(): Promise<boolean>
isMuted(): Promise<boolean>
getVolume(): Promise<number>
getPosition(): Promise<IPositionInfo>
interface IPositionInfo {
duration: number;
position: number;
}
play(): Promise<void>
pause(): Promise<void>
togglePlay(): Promise<void>
stop(): Promise<boolean>
toggleFullscreen(): Promise<void>
seek(position: number): Promise<void>
async jump(delta: number): Promise<void>
skipBack(): Promise<void>
skipForward(): Promise<void>
setVolume(volume: number): Promise<void>
toggleMute(): Promise<void>
nextAudioTrack(): Promise<void>
prevAudioTrack(): Promise<void>
nextSubtitles(): Promise<void>
prevSubtitles(): Promise<void>
getVariables(): Promise<IPlayerVariables>
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:
execute(commandId: MpcCommands, data?: Dictionary<any>): Promise<any>