Skip to content
/ yeah.js Public

A javascript library to convert video input to its excitement score.

License

Notifications You must be signed in to change notification settings

naosk8/yeah.js

Repository files navigation

yeah.js

A javascript library to convert video input into its excitement score.

CircleCI Codecov License: MIT Bower version

Demo page

A demo page on Github

Get started

1 - install

bower install yeah-js

2 - Usage

Plain usage

In HTML
<head>
  <script src='path/to/tracking.js'></script>
  <script src='path/to/yeah.js'></script>
  <script>
    function main() {
      videoElm = document.getElementById('targetVideo');
      // 1. Set a video element to be watched.
      yeah.setVideoElement(videoElm);

      // 2. Set options only if you want to arrange them.
      // yeah.setOptions(options);

      // 3. Set video src.
      if (navigator.getUserMedia) {
        navigator.getUserMedia({ audio: false, video: true }, function(stream) {
          yeah.playVideo(URL.createObjectURL(stream), 2000);
        }, function() {});
      } else {
        alert("This device doesn't support web camera. Please try sample movies listed on control panel above.")
      }

      // 4. Start capturing & Generate YEAH score: excitement barometer.
      yeah.startCaptureVideo(function successCallback(data) {
        console.log(data.yeah + '!');
      }, function failureCallback(error) {
        console.log(error);
      });

      // 5. Stop capturing as you like.
      setTimeout(function() {
        // stop capturing after 10sec.
        yeah.stopCaptureVideo();
      }, 10000);
    }
    document.addEventListener('DOMContentLoaded', main, false);
  </script>  
</head>
<body>
  <video id='targetVideo' autoplay playsinline></video>
</body>

With requireJS
Basically, the usage is same as Plain usage written above.
Differences are only these.

In HTML
<head>
  <script data-main='path/to/main.js' src='path/to/require.js'></script>
</head>

In Javascript(main.js)
// Use this line instead of calling DOMContentLoaded event.
require(['path/to/yeah'], function(yeah) {
  main();
});

Documents

API Documents written in YUIDoc

Reference for integration

Tools

Purpose Tool Command Setting
code check eslint npm run lint .eslintrc
unit test mocha mocha
test report istanbul npm run cover
test report Codecov.io npm run report
lint & test npm test package.json
CI Circle.io circle.yml
API doc YUIDoc yuidoc yuidoc.json

For contributors

All steps in this section assume npm and bower installed.

# Install yuildocjs
npm install -g yuidocjs

# Install devDependencies of npm modules
npm install

# Install devDependencies of bower components
bower install

# Create symlink for pre hook
ln -s -f ../../hooks/pre-commit .git/hooks/pre-commit

Library dependency

tracking.js (github)

License

MIT License Copyright (c) 2017 Nao Ito