{"id":20496343,"url":"https://github.com/vabatta/omx-manager","last_synced_at":"2025-04-13T18:21:11.005Z","repository":{"id":18278473,"uuid":"21443780","full_name":"vabatta/omx-manager","owner":"vabatta","description":"Manager for Rpi omxplayer","archived":false,"fork":false,"pushed_at":"2019-02-25T15:45:51.000Z","size":11002,"stargazers_count":23,"open_issues_count":3,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T15:57:19.742Z","etag":null,"topics":["javascript","loop","nodejs","omx-manager","omxplayer","raspberry-pi","video"],"latest_commit_sha":null,"homepage":"https://vabatta.github.com/omx-manager","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vabatta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-02T23:36:52.000Z","updated_at":"2022-01-06T22:25:17.000Z","dependencies_parsed_at":"2022-09-10T02:53:16.462Z","dependency_job_id":null,"html_url":"https://github.com/vabatta/omx-manager","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vabatta%2Fomx-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vabatta%2Fomx-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vabatta%2Fomx-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vabatta%2Fomx-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vabatta","download_url":"https://codeload.github.com/vabatta/omx-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317721,"owners_count":21083528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","loop","nodejs","omx-manager","omxplayer","raspberry-pi","video"],"created_at":"2024-11-15T18:06:43.974Z","updated_at":"2025-04-13T18:21:10.984Z","avatar_url":"https://github.com/vabatta.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Module omx-manager\n  1. [Presentation](#presentation)\n  2. [Features](#features)\n  3. [Usage](#usage)\n    1. [Basic usage](#basicusage)\n    2. [Multiple files](#multiple)\n    3. [Loop support](#loop)\n    4. [Arguments](#arguments)\n    5. [Status](#status)\n    6. [Videos directory](#videosdirectory)\n    7. [Videos extension](#videosextension)\n    8. [Omx command](#omxcommand)\n    9. [Other methods](#othermethods)\n    10. [Events](#events)\n  4. [Todo](#todo)\n\n**Note**: Complete **documentation** can be found on [github repo pages](http://vabatta.github.io/omx-manager/).\n\n\n\u003ca name=\"presentation\"\u003e\u003c/a\u003e\n## Presentation\n`omx-manager` is a Nodejs module providing a simple and complete interface to *official* [omxplayer](https://github.com/popcornmix/omxplayer). \u003cbr /\u003e\nYou can install through npm with `$\u003e npm install omx-manager`. \u003cbr /\u003e\n**Note:** You can also use a fork version, but you should adjust `omx-manager` according to your version. \u003cbr /\u003e\n**Note 2:** This README is made with *official* [omxplayer](https://github.com/popcornmix/omxplayer) in mind.\n\n\n\u003ca name=\"features\"\u003e\u003c/a\u003e\n## Features\n * Supports multiple files (see [below](#multiple))\n    * Provide a fallback **as** `omxplayer` doesn't support it natively\n * Supports loop (see [below](#loop))\n    * Provide a fallback **if** `omxplayer` doesn't support it natively\n * Supports all arguments\n    * Simply it doesn't filter any arguments\n * Built-in fix for `omxplayer` hanging (reported [here](https://github.com/popcornmix/omxplayer/issues/124))\n\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\n\u003ca name=\"basicusage\"\u003e\u003c/a\u003e\n### Basic usage\n```javascript\nvar OmxManager = require('omx-manager');\nvar manager = new OmxManager(); // OmxManager\nvar camera = manager.create('video.avi'); // OmxInstance\ncamera.play(); // Will start the process to play videos\n```\n**Note:** Whenever you `create()` something through the manager, you will get back an `OmxInstance` which serves to control the actual underlaying process.\n\n\n\u003ca name=\"multiple\"\u003e\u003c/a\u003e\n### Multiple files\n```javascript\nmanager.create(['video.avi', 'anothervideo.mp4', 'video.mkv']);\n```\n\n**WARNING:** at this time multiple files playing is not supported by *official* `omxplayer`, so `omx-manager` will handle it.\n\n\u003ca name=\"loop\"\u003e\u003c/a\u003e\n### Loop support\n*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:\n```javascript\nmanager.enableNativeLoop();\nmanager.create('video.avi', {'--loop': true});\n// this will start omxplayer with '--loop'\n```\nSo will be the `omxplayer` process itself to handle the loop for the video. \u003cbr /\u003e\n**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.\n\nOtherwise, 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:\n```javascript\n// manager.enableNativeLoop();\nmanager.create('video.avi', {'--loop': true});\nmanager.enableNativeLoop();\nmanager.create(['video.avi', 'anothervideo.avi'], {'--loop': true});\n// both will start omxplayer without '--loop'\n```\nSo will be the `omx-manager` to handle the loop, providing a fallback (see below).\n\n#### Loop fallback\n*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.\n\n\n\u003ca name=\"arguments\"\u003e\u003c/a\u003e\n### Arguments\nAny arguments declared in the `omxplayer` repository.\u003cbr /\u003e\nTo set an argument with value use `'argument': \u003cvalue\u003e` otherwise, if argument doesn't have a value, use `'argument': true`.\n\n**Note**: If you set an argument that `omxplayer` doesn't support or declare, `omx-manager` will anyway add it to the omx process spawn.\nThis mean that will be the `omxplayer` itself to handle the argument.\n\n**WARNING:** About **loop** see [above](#loop).\n\n#### Example object\n```javascript\n{\n  '-o': 'hdmi',\n  '-p': true,\n  '--vol': 13,\n  '-p': true,\n  '--argument-that-doesnt-exists': true //this will be passed to omx process (see note above)\n}\n```\n\n#### Example play\n```javascript\nmanager.create('video.mp4', {'-p': true}); // enables audio passthrough\nmanager.create('video.mp4', {'-o': 'hdmi'}); // HDMI audio output\n```\n\n\n\u003ca name=\"status\"\u003e\u003c/a\u003e\n### Status\n```javascript\nvar status = camera.getStatus();\n```\n\nReturn an object with the current status.\n\nComposition\n```javascript\n{\n  pid: number|null,\n  videos: Array\u003cstring\u003e,    // videos array passed to play(videos, args)\n  current: string, // current video playing\n  args: object,  // args object passed to play(videos, args)\n  playing: boolean  // true if not paused, false if paused\n}\n```\n\n\n\u003ca name=\"videosdirectory\"\u003e\u003c/a\u003e\n### Videos directory\n```javascript\nmanager.setVideosDirectory('my/base/path');\n```\nSet where to look for videos. Useful when all videos are in the same directory.\nDefault to  `./`\n\nInstead of this:\n```javascript\nmanager.create(['/home/pi/videos/foo.mp4', '/home/pi/videos/bar.mp4', '/home/pi/videos/baz.mp4']);\n```\n\nIt's possible to use this shortcut:\n```javascript\nmanager.setVideosDirectory('/home/pi/videos/');\nmanager.create(['foo.mp4', 'bar.mp4', 'baz.mp4']);\n```\n\n\n\u003ca name=\"videosextension\"\u003e\u003c/a\u003e\n### Videos extension\n```javascript\nmanager.setVideosExtension('.extension');\n```\nSet an extension for videos. Useful when all videos share the same format.\nDefault to  `''`\n\n**Note:** You must set a full extension **including** initial dot. In fact, this is just a *post-fix* to every path.\n\nInstead of this:\n```javascript\nmanager.create(['foo.mp4', 'bar.mp4', 'baz.mp4']);\n```\n\nIt's possible to use this shortcut:\n```javascript\nmanager.setVideosExtension('.mp4');\nmanager.create(['foo', 'bar', 'baz']);\n```\n\n\n\u003ca name=\"omxcommand\"\u003e\u003c/a\u003e\n### Omx command\n```javascript\nmanager.setOmxCommand('/path/to/my/command');\n```\nSet the default command to spawn.\nDefault to  `omxplayer`\n\nUseful when `omxplayer` isn't in your path or you want to specify a different name for the spawn.\n```javascript\nmanager.setOmxCommand('/usr/local/bin/omxplayer-fork');\nmanager.create('video.avi'); // the process is spawned calling '/usr/local/bin/omxplayer-fork'\n```\n\n\n\u003ca name=\"othermethods\"\u003e\u003c/a\u003e\n### Other methods\nRefer to [documentation](http://vabatta.github.io/omx-manager/) for complete information about api.\n\n\n\u003ca name=\"events\"\u003e\u003c/a\u003e\n### Events\n```javascript\n// successfully started a video or resumed from pause\ncamera.on('play', function(video) {});  \n\n// successfully paused a video\ncamera.on('pause', function() {});\n\n// successfully stopped a video (omxplayer process ends)\ncamera.on('stop', function() {});\n\n// videos to play are ended (never called if you are in a loop condition)\ncamera.on('end', function() {});\n```\n\nRefer to [documentation](http://vabatta.github.io/omx-manager/) for complete information about events.\n\n\n\u003ca name=\"todo\"\u003e\u003c/a\u003e\n## TODO\n\nYour suggestions are welcome!\n\n * Syncing videos between different devices through a custom server (built-in)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvabatta%2Fomx-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvabatta%2Fomx-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvabatta%2Fomx-manager/lists"}