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

@avvio-reply/jplayer

v1.2.7

Published

Stitched-frame player with custom event controls

Downloads

39

Readme

JPlayer

Writes image frames from stitched content to target canvas.

How it works

JPlayer is a configurable stills player to create highly flexible video playback. Finite control is possible through a 'frame event' mechanism.

Playback can be either forward or reverse, with options to loop, even down to a subset of frames if desired.

Event triggers can be configured by frame number or by custom naming allowing intuitive and descriptive event handlers to be written.

JPlayer requires Preloader and will include this when installed.

REQUIRE

require('@avvio-reply/jplayer')(require('jquery'))

USAGE - Configuration:

Define an object with one or more scenes with the following schema:

var root = '/content/images/scenes/'
    , content = {
        scenes: [
        {
            name: "<scene-name>",   // key name of scene (some methods accept this name as identifier)
            preload: 100,           // percentage of resources that must be loaded before the scene is ready to play

            motion: {               // MOTION Schema:
                catalog: root,          // root of stitched image resources
                sheetfrom: 1,           // start of stitched image file range - stitched image resources must be named in numerical sequential order
                sheetto: 29,            // end of stitched image file range
                sheetsize: 4,           // the number of stills within the file - stills are assumed to be arranged left to right 
                framerate: 30,          // playback number of frames per second for this scene
                framewidth: 832,        // width of a single frame within stitched files - all frames must have equal dimensions
                frameheight: 468,       // height of a single frame within stitched files - all frames must have equal dimensions
                loop: false             // True or False tells JPlayer whether to run through all frames in a continuous loop
            },

            events: {               // EVENTS Schema:
                custom: {               // custom group of named events
                    <named-event-a>: [ 1 ],         // named event providing the frame or frames that trigger the name
                    <named-event-b>: [ 116, 127 ]   // named event providing the frame or frames that trigger the name
                }
            }
        }
    }

USAGE - Insantiation:

  this.$canvas.jPlayer({

    scenes: Config.content
        , framerate: 20
        , regulateFramerate: false

        , frameEventCallback: function(e){
            if (e.events.introStart) {


            } else if (e.events.introOver) {

                /* animated intro complete - load next question */
                self.renderQuestion();

            }
            else if (e.events.resultStart){

                self.assets['whistle'].play();

            }
            else if (e.events.resultKick){

                self.assets['kick'].play();

            }
            else if (e.events.resultKnown){

                /* ensure result audios are reset */
                self.assets['goal'].pause();
                self.assets['goal'].currentTime = 0;
                self.assets['miss'].pause();
                self.assets['miss'].currentTime = 0;

                var result = self.isLastAnsweredCorrectly() ? 'goal' : 'miss';

                if (self.assets[result])
                    self.assets[result].play();

                /* update the score indicator */
                $($('#bonusScoreList li').get(self.currentQuestion-1))
                    .addClass('is-' + result);

            }
            else if (e.events.resultOver) {
                
                if (self.currentQuestion == 5){

                    endLoop = true;
                    setTimeout(function(){
                        location.href = '/';
                    }, 3500);

                } else
                {   /* re-run intro because another question is pending */
                    self.playScene('intro');
                }
            }
        }

        , preloadCallback: function(e){}

        , endLoopCallback: function(e){}
        , sceneCreatedCallback: function(e){}
        , sceneReadyCallback: function(e){}
  });

USAGE - Methods

Play

    $('#user-canvas').jPlayer('play')

Stop

    $('#user-canvas').jPlayer('stop')

SetSceneByNumber

    $('#user-canvas').jPlayer('setSceneByNumber', newSceneNumber)

SetSceneByName

    $('#user-canvas').jPlayer('setSceneByName', newSceneName)

Forward

    $('#user-canvas').jPlayer('forward')

Reverse

    $('#user-canvas').jPlayer('reverse')

Toggle

    $('#user-canvas').jPlayer('toggle')

Playing


    $('#user-canvas').jPlayer('playing')

GetScene


    $('#user-canvas').jPlayer('getScene')

SetFrame

Change the frame number during playback whether forward or reverse. 

    $('#user-canvas').jPlayer('setFrame', (int)newFrame)

SetFrameRate

Changes the current playback frame-rate (per second). Better results are possible when newRate divides evenly into 60
given HTML5 canvas is 60fps.

Option regulate is only effective when JPlayer is in differential mode. Regulate attempts to correct framerate syncing
with uneven framerates, such as 24fps.


    $('#user-canvas').jPlayer('setFramerate', (int)newRate, (bool)regulate)

GetPreloadState

Returns object representing the load state of required resources as determined by the player configuration.

    $('#user-canvas').jPlayer('getPreloadState')

IsAtStart

Returns bool True/False whether the current scene is the first scene:

    $('#user-canvas').jPlayer('isAtStart')

IsAtEnd

Returns bool True/False whether the current scene is the last scene:

    $('#user-canvas').jPlayer('isAtEnd')

LOCAL DEV:

"@avvio-reply/jplayer": "file:///development/node/modules/jplayer"