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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nmp-player

v1.1.0

Published

Play videos in minecraft using minecraft-protocol

Downloads

26

Readme

nmp-player

Node Minecraft Protocol Video Player

Description

This library allows you to display videos using the 'map' item in minecraft. Currently supports:

Contributing

Feel free to open an issue or a pull request! :D

Install

Available on npm npm install nmp-player

API

NMP-Player

  • VideoPlayer
  • Video
  • Converter

Class: VideoPlayer([server], [options]) extends EventEmitter

A video player. Extends EventEmitter. Args:

  • Server: minecraft-protocol server.
  • Options: Object
  • options.ID: number
  • options.frame: function, if given will call with buffer data to display frames

Example

const { VideoPlayer } = require('nmp-player')

<...>

videoplayer = new VideoPlayer(server)

videoplayer.play('./video.json')

videoplayer.on('play', (video) => console.log() )

Properties

videoplayer.loaded

The loaded video. Is Video or null.

videoplayer.ID

A number. Represents the ID of the video player. Used for sending map packets. Default: 0

Functions

videoplayer.giveMaps([options])

Gives a map with the video player's ID to all the players in the server.

  • options: Object
  • options.slot: The slot to give the item to. Defaults to 36.

videoplayer.load(src)

Loads a video.

videoplayer.play([resource])

Plays the loaded video, loads the resource if given first.

  • resource: A source Returns: Promise (resolves after video stops playing)

Events

"finished" (video)

Fires when a video is finished.

"play" (video)

Fires when a video starts playing.

"frame" (video, buffer, frameNo)

Fires every frame in a video.

  • video: Video
  • buffer: Buffer data of the frame.
  • frameNo: Number of the frame

Class: SongPlayer([server])

A song player. Plays .nbs files, using nbs.js. Server is optional, but you should write your own _note method. Extends EventEmitter.

Example

const { SongPlayer } = require('nmp-player')

<...>

songplayer = new SongPlayer()

songplayer._note = function(packet){
	packet.x = 0
	packet.y = 0
	packet.z = 0
	client.write('sound_effect', packet)
}

songplayer.play('./song.nbs')

Properties

songplayer.song

The loaded Song

songplayer.tick

The current tick

songplayer.interval

The interval of the song player

songplayer.playing

Boolean representing if a song is playing

Functions

songplayer.load(src)

Try to load src, can be:

  • Song
  • String (filename)

songplayer.play([src])

Plays song. src is same as load()

songplayer._note(packet)

Handles notes, you must set this to your own function.

  • The packet name is 'sound_effect'
  • You must give x, y, z to the packet, calculate this by multiplying the players coordinate by 8.

songplayer.stop()

Stops playing song

Events

"play" (song)

Fires when a song starts playing.

"stop"

Fires when the songplayer is manually stopped.

"end"

Fires when song ends.


Class: Video

Used internally. You should not generally initialize this class yourself. Either way, constructor:

  • videoplayer: VideoPlayer
  • data: Video Data (An array of hex-encoded buffer strings)
  • meta: Object containing metadata of the video.

Properties

video.FPS

Number. The FPS of the video.

video.playing

Boolean representing if the video is currently playing or not.

video.data

An array of buffers that represent the frames.

video.meta

An object for video metadata. If the video is loaded from a file, it can contain 'filename'


Class: Converter

Static Methods

Converter.extractFrames([options])

Extracts frames using ffmpeg.

  • options: Object
  • options.filename: Path to the video or name of the video. Default: "./video.mp4"
  • options.ffmpegPath: Path to ffmpeg. Default: "%FFMPEG_PATH%"
  • options.path: Name of the folder that you want to extract the frames to. Default: "frames" Returns: Promise (resolves when ffmpeg finishes)

Converter.convertFrames([path], [delete])

Converts frames from a folder. Use this after Converter.extractFrames() Note: This method does not save the converted frames. Look for the output.

  • path: Folder of the frames. Default: "frames"
  • delete: Deletes the converted frame or not. Default: true Returns: Promise<Array>

Converter.convertToMap(buffer)

Converts buffer to map data (resized to 128x128). I dont really know how to handle the output, check code? This method just does resizeForMap and toMap.

  • buffer: image Returns: Promise

Converter.toMap(buffer)

Converts buffer to map data. Warn: Does not resize.

  • buffer: image (pixels) Returns: Promise

Converter.resizeForMap(buffer[, width][, height])

Resizes the image. (128x128)

  • buffer: image (pixels)
  • width: number (Default 128)
  • height: number (Default 128) Returns: Promise

Function: downloadYoutube(URL, [filename])

Downloads a video.

  • URL: Video URL
  • filename: Name of the file to save to. Default: "./video.mp4" Returns: EventEmitter
    • Events:
    • "progress" (percentage)
    • "finish" (filename)

Function: convertYoutube(URL)

Downloads, extracts and converts the frames, then saves the video as "video.json"

  • URL: Video URL Returns: Promise<"video.json">

Source

Either

  • File path of a video json
  • A video json
  • An array of hex-encoded buffer strings

Update Logs

1.0.2

  • Added SongPlayer
  • Server is now optional for VideoPlayer
  • Added the ability to add custom frame display functions to VideoPlayer

1.0.1

  • Changed Converter class function names to be more understandable