Module omx-manager
- Presentation
- Features
- Usage
- Basic usage
- Multiple files
- Loop support
- Arguments
- Status
- Videos directory
- Videos extension
- Omx command
- Other methods
- Events
- Todo
Note: Complete documentation can be found on github repo pages.
Presentation
omx-manager
is a Nodejs module providing a simple and complete interface to official omxplayer.
You can install through npm with $> npm install omx-manager
.
Note: You can also use a fork version, but you should adjust omx-manager
according to your version.
Note 2: This README is made with official omxplayer in mind.
Features
- Supports multiple files (see below)
- Provide a fallback as
omxplayer
doesn't support it natively
- Provide a fallback as
- Supports loop (see below)
- Provide a fallback if
omxplayer
doesn't support it natively
- Provide a fallback if
- Supports all arguments
- Simply it doesn't filter any arguments
- Built-in fix for
omxplayer
hanging (reported here)
Usage
Basic usage
var OmxManager = ;var manager = ; // OmxManagervar camera = manager; // OmxInstancecamera; // Will start the process to play videos
Note: Whenever you create()
something through the manager, you will get back an OmxInstance
which serves to control the actual underlaying process.
Multiple files
manager;
WARNING: at this time multiple files playing is not supported by official omxplayer
, so omx-manager
will handle it.
Loop support
Official omxplayer
supports native loop with --loop
flag (but only for 1 video), this means that the --loop
flag will be appended to the process ONLY if the videos argument contains exactly one video:
manager;manager;// this will start omxplayer with '--loop'
So will be the omxplayer
process itself to handle the loop for the video.
WARNING: this means that you won't get events play
and stop
because the underlaying process cannot notify omx-manager
of the new start. For uniformity you shouldn't use the native loop.
Otherwise, when you pass more than one video with a loop flag or you didn't enable the nativeLoop
, omx-manager
will ignore that flag and provide a built-in fallback:
// manager.enableNativeLoop();manager;manager;manager;// both will start omxplayer without '--loop'
So will be the omx-manager
to handle the loop, providing a fallback (see below).
Loop fallback
Official omxplayer
doesn't supports native loop over multiple files, so omx-manager
provide a fallback: once a video is ended, another process is spawned.
Arguments
Any arguments declared in the omxplayer
repository.
To set an argument with value use 'argument': <value>
otherwise, if argument doesn't have a value, use 'argument': true
.
Note: If you set an argument that omxplayer
doesn't support or declare, omx-manager
will anyway add it to the omx process spawn.
This mean that will be the omxplayer
itself to handle the argument.
WARNING: About loop see above.
Example object
'-o': 'hdmi' '-p': true '--vol': 13 '-p': true '--argument-that-doesnt-exists': true //this will be passed to omx process (see note above)
Example play
manager; // enables audio passthroughmanager; // HDMI audio output
Status
var status = camera;
Return an object with the current status.
Composition
pid: number|null videos: Array<string> // videos array passed to play(videos, args) current: string // current video playing args: object // args object passed to play(videos, args) playing: boolean // true if not paused, false if paused
Videos directory
manager;
Set where to look for videos. Useful when all videos are in the same directory.
Default to ./
Instead of this:
manager;
It's possible to use this shortcut:
manager;manager;
Videos extension
manager;
Set an extension for videos. Useful when all videos share the same format.
Default to ''
Note: You must set a full extension including initial dot. In fact, this is just a post-fix to every path.
Instead of this:
manager;
It's possible to use this shortcut:
manager;manager;
Omx command
manager;
Set the default command to spawn.
Default to omxplayer
Useful when omxplayer
isn't in your path or you want to specify a different name for the spawn.
manager;manager; // the process is spawned calling '/usr/local/bin/omxplayer-fork'
Other methods
Refer to documentation for complete information about api.
Events
// successfully started a video or resumed from pausecamera; // successfully paused a videocamera; // successfully stopped a video (omxplayer process ends)camera; // videos to play are ended (never called if you are in a loop condition)camera;
Refer to documentation for complete information about events.
TODO
Your suggestions are welcome!
- Syncing videos between different devices through a custom server (built-in)