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

omxdirector

v0.1.2

Published

Provide a nodejs interface for omxplayer (Raspberry Pi player). Support multiple file and loop.

Downloads

26

Readme

omxdirector

Nodejs module providing a simple interface to omxplayer.

Supports multiple files playing and loops. It's capable of seamless loops if omxplayer supports it natively. When omxplayer doesn't support loops, this module handles loops respawning omxplayer process.

Usage

Basic usage

var omx = require('omxdirector');
omx.play('video.avi');

Multiple files

omx.play(['video.mp4', 'anothervideo.mp4', 'foo.mp4'], {loop: true});

WARNING: at this time, multiple files playing is not supported by official omxplayer. If using with a fork version, you must enable native loop support (see below).

Options

  • audioOutput "local" or "hdmi" as -o omxplayer argument. If not specified or "default" is system default.
  • loop true to enable --loop omxplayer argument. Default is false.

WARNING: at this time, loop is not supported by official omxplayer. If using with a fork version, you must enable native loop support.

Example

omx.play('video.mp4', {loop: true}); // enables loop
omx.play('video.mp4', {audioOutput: 'local'}); // analog audio output

Native loop support

If you have a versione of omxplayer supporting native loop with --loop flag, you can enable it by calling:

var omx = require('omxdirector').enableNativeLoop();

Loop fallback

If using with standard omxplayer, a fallback is provided: once a video is finished, another process of omxplayer is launched. It support multiple files and infinite loop. Although this works fine, native support is better because there's no gap between video.

Status

omx.getStatus()

Return an object with current status:

If process is not running:

{ loaded: false }

If process is running:

{
  loaded: true,
  videos: <Array>,    // videos array passed to play(videos, options)
  settings: <Object>,  // default settings or options object passed to play(videos, options)
  playing: <boolean>  // true if not paused, false if paused
}

Video directory

omx.setVideoDir(path);

Set where to look for videos. Useful when all videos are in the same directory.

Instead of this:

omx.play(['/home/pi/videos/foo.mp4', '/home/pi/videos/bar.mp4', '/home/pi/videos/asdasd.mp4']);

It's possible to use this shortcut:

omx.setVideoDir('/home/pi/videos/');
omx.play(['foo.mp4', 'bar.mp4', 'asdasd.mp4']);

Video suffix

omx.setVideoSuffix(suffix);

Set a suffix for videos. Useful when all videos share the same format.

Instead of this:

omx.play(['foo.mp4', 'bar.mp4', 'asdasd.mp4']);

It's possible to use this shortcut:

omx.setVideoSuffix('.mp4');
omx.play(['foo', 'bar', 'asdasd']);

Other methods

omx.pause();     // pause the video
omx.play();      // resume video playing
omx.stop();      // stop video playing and terminate omxplayer process
omx.isLoaded();  // return true if omxprocess is running
omx.isPlaying(); // return true if omxprocess is running and video is not paused
omx.volup();     // Increases the volume one notch
omx.voldown();   // Decreases the volume one notch

Events

omx.on('load', function(files, options){}); // video successfully loaded (omxprocess starts)
omx.on('play', function(){});  // when successfully started or resumed from pause
omx.on('pause', function(){}); // when successfully paused
omx.on('stop', function(){});  // when successfully stopped (omxplayer process ends)

TODO

  • Emit event when each video start, stop etc...
  • Implement forward/backward.
  • Enable a fallback for loop and multiple files when native support is disabled.