moroboxai-player-react
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-alpha.25 • Public • Published

moroboxai-player-react

NPM version Node.js CI gitHub license Code Quality: Javascript Total Alerts

Embeddable player for running MoroboxAI games in React.

Installation

Using npm:

npm install moroboxai-player-react --save

Or:

git clone https://github.com/moroboxai/moroboxai-player-react.git
cd moroboxai-player-react
npm i
npm run build

Usage

Setup a simple React app with:

npx create-react-app my-app --template typescript

Add moroboxai-player-react as a dependency:

cd my-app
npm install moroboxai-player-react --save

Replace src/App.tsx with:

import "./App.css";
import Player from "moroboxai-player-react";

function App() {
    return (
        <div className="App">
            <header className="App-header">
                <Player
                    url="https://raw.githubusercontent.com/moroboxai/moroboxai-games/master/games/pong/"
                    splashart="https://raw.githubusercontent.com/moroboxai/moroboxai-games/master/games/pong/assets/splashart.png"
                    width={256}
                    height={256}
                />
            </header>
        </div>
    );
}

export default App;

Build and start a local server to see the result:

npm run build
npm run start

Props

Name Type Default Description
url string URL of the game
splashart string URL of the placeholder image displayed before the game is loaded
width number Width of the div element
height number Height of the div element
resizable boolean true If the game can resize the player
className string Class name for the div container
autoPlay boolean false Auto play the game after the player is initialized
speed number 1 Speed of the game
onReady func noop Signature: function() => void
Function called when the game is loaded and ready
onMount func noop Signature: function(player: IPlayer) => void
Function called when the component is mounted

License

This content is released under the MIT License.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.0-alpha.250latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.0-alpha.250
0.1.0-alpha.240
0.1.0-alpha.230
0.1.0-alpha.220
0.1.0-alpha.210
0.1.0-alpha.200
0.1.0-alpha.190
0.1.0-alpha.180
0.1.0-alpha.170
0.1.0-alpha.160
0.1.0-alpha.150
0.1.0-alpha.140
0.1.0-alpha.130
0.1.0-alpha.120
0.1.0-alpha.110
0.1.0-alpha.100
0.1.0-alpha.80
0.1.0-alpha.70
0.1.0-alpha.60
0.1.0-alpha.50
0.1.0-alpha.40
0.1.0-alpha.30
0.1.0-alpha.20
0.1.0-alpha.10

Package Sidebar

Install

npm i moroboxai-player-react

Weekly Downloads

0

Version

0.1.0-alpha.25

License

MIT

Unpacked Size

1.62 MB

Total Files

17

Last publish

Collaborators

  • moroboxai