Basic control over Media Player Classic - Home Cinema via http api.
Enable web interface in mpc-hc settings.
npm i mpc-hc-control
const {MpcControl} = require("mpc-hc-control");
const mpcApi = new MpcControl("localhost", 13579);
mpcApi.openFile("c:\\video.mkv"));
mpcApi.setVolume(75);
Basic methods list:
/**
* @filePath - path to video file
*/
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>
/**
* @position - new position in ms
*/
seek(position: number): Promise<void>
/**
* @delta - delta from current position in ms
*/
async jump(delta: number): Promise<void>
skipBack(): Promise<void>
skipForward(): Promise<void>
/**
* @volume - new volume in percents
*/
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:
/**
* @commandId - any mpc-hc supported command from commands/mpcCommands.ts
* @data - additional data provided in to api call
*/
execute(commandId: MpcCommands, data?: Dictionary<any>): Promise<any>