GithubHelp home page GithubHelp logo

matt-oakes / cogs-client-react-lib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clockwork-dog/cogs-client-react-lib

0.0 1.0 0.0 276 KB

COGS client React components

Home Page: https://www.npmjs.com/package/@clockworkdog/cogs-client-react

TypeScript 100.00%

cogs-client-react-lib's Introduction

COGS Client React library

Create content for your COGS Media Master

Add to your project

npm install --save @clockworkdog/cogs-client-react

or

yarn add @clockworkdog/cogs-client-react

Usage

Import the library

import {
  CogsConnectionProvider,
  VideoContainer,
  Timer,
  Hint,
  useIsConnected,
  useAudioPlayer,
  useIsAudioPlaying,
} from '@clockworkdog/cogs-client-react';

or

const {
  CogsConnectionProvider,
  VideoContainer,
  Hint,
  Timer,
  useIsConnected,
  useAudioPlayer,
  useIsAudioPlaying,
} = require('@clockworkdog/cogs-client-react');

then

function App() {
  return (
    <CogsConnectionProvider audioPlayer videoPlayer>
      <MyComponent />
    </CogsConnectionProvider>
  );
}

function MyComponent() {
  const cogsConnection = useCogsConnection();
  const isConnected = useIsConnected(cogsConnection);

  const audioPlayer = useAudioPlayer();
  const isAudioPlaying = useIsAudioPlaying(audioPlayer);

  return (
    <div>
      <div>Connected: {isConnected}</div>
      <div>Audio playing: {isAudioPlaying}</div>
      <div style={{ fontSize: 100 }}>
        {/* The time from the adjustable timer plugin in the format 'MM:SS' */}
        <Timer center />
      </div>
      <div style={{ fontSize: 20 }}>
        {/* The latest text hint as a string */}
        <Hint />
      </div>
      {/* Specify where you want the video to be displayed. Leave this out for default fullscreen behavior */}
      <VideoContainer style={{ position: 'absolute', top: 100, left: 100, width: 400, height: 300 }} />
    </div>
  );
}

Local development

When developing locally you should connect to COGS in "simulator" mode by appending ?simulator=true&t=media_master&name=MEDIA_MASTER_NAME to the URL. Replace MEDIA_MASTER_NAME with the name of the Media Master you set in COGS.

For example, with your custom content hosted on port 3000, http://localhost:3000?simulator=true&t=media_master&name=Timer+screen will connect as the simulator for Timer screen.

Chrome permissions

Chrome's autoplay security settings mean that you will need to interact with the page before audio or video will play. You can disable this warning when developing by pressing ℹī¸ in Chrome's URL bar, opening Site settings, and setting Sound to Allow.

Using create-react-app

We suggest you use our create-react-app template.

Or, if you're using create-react-app for your project, you'll need to configure the build to work with a relative path, as when accessed by a Media Master your project will not be served from the root path. This can be achieved by adding the following to your package.json:

"homepage": ".",

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.