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

vlcplayer-node

v0.5.3

Published

A library for controlling VLC player on Raspberry PI.

Downloads

16

Readme

vlcplayer-node

A library for controlling VLC player on Raspberry PI. The current version is tested on a Rapsberry PI 2GB of RAM without any UI.

Installation

sudo apt install vlc
npm install --save vlcplayer-node

Usage

VlcPLayer is not an event emitter. Your logic have to take in consideration that you are handling a playlist. With this paradigm, you have to take video timing in consideration if you want to repeat a sequence or play something else based on external events. Look at the following example:

import { VlcPlayer, sleep } from "vlcplayer-node"

let mediasHome = "/var/medias/";
const VIDEOS = {
    BadWeather: `${mediasHome}2019_sc02_067_v001_BUFFER1-1080.mp4`, // 20 seconds
    Tornado: `${mediasHome}2019_sc02_067_v001_TRIGGER1-1080.mp4`,   // 20 seconds
    Flying: `${mediasHome}2019_sc02_067_v001_BUFFER2-1080.mp4`,     // 20 seconds
    FallDown: `${mediasHome}2019_sc02_067_v001_TRIGGER2-1080.mp4`,  // 13 seconds
    CropField: `${mediasHome}2019_sc02_067_v001_BUFFER3-1080.mp4`   // 20 seconds
};

let player = new VlcPlayer();
await player.open();
for (let key in VIDEOS) {
    await player.add(VIDEOS[key]);
}
await player.play(VIDEOS.BadWeather);
await player.repeat("on");
await sleep(25);
await player.play(VIDEOS.Tornado);
await player.repeat("off");
await sleep(22);
await player.repeat("on");
await sleep(30);
await player.play(VIDEOS.FallDown);
await player.repeat("off");
await sleep(15);
await player.repeat("on");
await sleep(30);
await player.close();

The code adds all videos to the playlist, in declaration order. After the for loop, the first video (BadWeather) is displayed in the paused state, but you may not notice that since there is no sleep before the play command is called. Then the whole thing is played in that sequence:

  1. The BadWeather video starts.
  2. Activate the repeat mode.
  3. Sleep 25 seconds. Since BadWather is only 20 seconds long, it will repeat and play for another 5 seconds.
  4. The Tornado video starts.
  5. Turn off video repetion.
  6. Sleep 22 seconds. Since the Tornado video is 20 seconds long, the Flying video will start right after.
  7. Turn on video repetition. The Flying video will repeat itself.
  8. Waiting 30 seconds means that the Flying video repeats and play for another 10 seconds.
  9. Jump to the FallDown video.
  10. Turn off video repetion.
  11. Waiting for 15 seconds will let the player jump to CropField since FallDown duration is only 13 seconds.
  12. Turn on video repetition. The CropField video will repeat itself.
  13. Waiting 30 seconds means that the CropField video repeats and play for another 10 seconds.
  14. The player shuts down.

From there, you got the gist of it. You could as well repeat the whole sequence by wrapping 1-12 into a while loop instead of closing. You could aso leave the CropField video run indefinitely or until a given event.

You can also call player.exec() to execute any rc command that is not implemented right away. If you think that there is some other good abstraction to add to the player, feel free to implement that function send a pull request my way! Want to make it work under another OS? Don't ask me what I can do for you, ask yourself what you can do to make it happend... and send me a pull request with your own cross platform implemetation!

I developped this module after the OMX Player deprecation for my escape games consulting work. Tested and working on Raspberry PI 4 with the minimal Raspbian image (console only).