mpv-controller
v1.3.3
Published
Controller for mpv media player.
Downloads
23
Maintainers
Readme
mpv-controller
Node.js module which controls mpv media player written in ES2015.
npm: https://www.npmjs.com/package/mpv-controller
Installation
npm install mpv-controller
Usage
Example
const mpv = require('mpv-controller');
var player = new mpv(status => {
console.log(status);
});
player.limitStatusMessages(5);
player.play("/path/to/video.mkv");
setTimeout(player.pause.bind(player), 5000); // Pauses after 5 seconds
Creating an instance
var player = new mpv(statusListener);
where statusListener will receive an object containing playback status on the form
{
playing: true,
buffering: false,
elapsed: 282,
total: 421,
elapsedStr: "00:04:42",
totalStr: "00:07:01",
progress: 0.6698
}
or
{
exit: true
}
if mpv has been closed.
Play a video
player.play(video [, subtitles [, mpv-flags]]);
Pause/resume
player.togglePause();
Other commands
player.stop();
player.seekForward(); // Seek 5 seconds forwards
player.seekBackward(); // Seek 5 seconds backwards
player.bigSeekForward(); // Seek 30 seconds forwards
player.bigSeekBackward(); // Seek 30 secons Backwards
player.seek(seconds [, mode]); // See mpv documentation for modes
player.displayStatus(); // Displays status hud
player.increaseSpeed();
player.decreaseSpeed();
player.resetSpeed();
player.decreaseVolume();
player.increaseVolume();
player.mute();
player.toggleFullscreen();
player.exitFullscreen();
player.toggleSubtitle();
player.addSubtitle(filepath);
Limit the amount of status messages
Will show every mod update returned by mpv. mod = 5 will show every fifth update.
player.limitStatusMessages(mod);
Sending flags to mpv
player.play("https://www.youtube.com/watch?v=rOOdfugvsIY", ["--fs", "--ytdl-format=best"]);
Dependencies
- mpv
Contact
- http://oskarnyberg.com
- [email protected]
Licence
MIT: https://opensource.org/licenses/MIT