npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vlc-player-controller

v0.0.5

Published

Spawn media player app and control playback

Downloads

1

Readme

media-player-controller

License npm Downloads Donate Donate

Spawn media player app and control playback. Also allows reading player state through socket or web connection.

Supported Media Players

| Player | Linux | Win | MacOS | | :--------: | :---: | :---: | :---: | | mpv | yes | no | ? | | vlc | yes | yes | ? |

? - untested (feedback is welcome)

Player config

var player = new PlayerController({
  app: 'mpv',                         // Media player name to use (mpv/vlc)
  args: [],                           // Player command line args (array of strings)
  cwd: null,                          // Current working dir for media player spawn
  media: '/path/to/video.mp4',        // Media to load on player launch (required)
  ipcPath: '/tmp/media-ctl-socket',   // Path to socket connection file (mpv only)
  httpPort: 9280,                     // HTTP port for local communication (vlc only)
  httpPass: null,                     // HTTP login password (vlc only, defaults to player name)
  detached: false                     // Spawn player as detached process
});

Player functions

Each playback controlling function have an optional callback with eventual error. They are executed asynchronously by default and can be used after playback-started event.

.launch()                    // Launch media player
.quit()                      // Stop media player process

.play()                      // Resume playback
.pause()                     // Pause playback
.cyclePause()                // Cycle play/pause
.load(mediaPath)             // Load new media file (without closing player)
.seek(position)              // Seek to position (value in seconds)
.setVolume(value)            // Adjust player volume (value 0-100)
.setSpeed(value)             // Adjust playback speed (normal: 1.0)
.setRepeat(isEnabled)        // Repeat playback (true or false)
.cycleVideo()                // Switch active video track
.cycleAudio()                // Switch active audio track
.cycleSubs()                 // Switch active subtitle track
.addSubs()                   // Add subtitles to currently playing video
.setFullscreen(isEnabled)    // Enable or disable fullscreen (true or false)
.cycleFullscreen()           // Toggle fullscreen on/off
.keepOpen(isEnabled)         // Keep player open after playback (true or false)

.command([args])             // Custom command for IPC/HTTP (array of args)

Please note that some commands are not yet implemented for every player (most of them are). If a command is not available for currently used player, callback will return error with a message saying so.

Available events

.on('app-launch')            // Emited on media player app launch
.on('playback-started')      // Playback started and player can now be controlled
.on('playback', data)        // Data object with current playback event
.on('app-exit', code)        // Exit code emited on media player app close

Usage Example

const PlayerController = require('media-player-controller');

var player = new PlayerController({
  app: 'mpv',
  args: ['--fullscreen'],
  media: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'
});

player.on('playback', console.log);

player.on('playback-started', () => {
  console.log('Playback started. Player can now be controlled');
});

player.on('app-exit', (code) => {
  console.log(`Media player closed. Exit code: ${code}`);
});

player.launch(err => {
  if(err) return console.error(err.message);
  console.log('Media player launched');
});

Donation

If you like my work please support it by buying me a cup of coffee :-)

PayPal