# @mycujoo/player-core

> Based on video.js project

Latest version **1.1.7-rc.0** (published 2023-04-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mycujoo/player-core
pnpm add @mycujoo/player-core
yarn add @mycujoo/player-core
bun add @mycujoo/player-core
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7-rc.0 |
| Published | 2023-04-28 |
| First published | 2020-05-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | yneleven, berker93, vikkivi, pvmnt, farzad-mycujoo, mycujoo.tv, radev83, aandrei, pplaatje, oleksiih, antonella.manilla, thecodeassassin, rgalus, mycujoomats, alaandrei |

## Links

- npm: https://www.npmjs.com/package/@mycujoo/player-core
- npm.io page: https://npm.io/package/@mycujoo/player-core

## Recent versions

- 1.1.7-rc.0 (latest) — 2023-04-28
- 1.0.0-rc.1 (next) — 2021-02-02
- 1.1.6 — 2023-03-24
- 1.1.5 — 2023-03-21
- 1.1.5-rc.0 — 2023-03-20
- 1.1.4 — 2023-03-20
- 1.1.3 — 2022-10-19
- 1.1.2 — 2022-10-18
- 1.1.1 — 2022-09-16
- 1.1.1-rc.4 — 2022-09-16
- 1.1.1-rc.3 — 2022-09-16
- 1.1.1-rc.2 — 2022-09-15
- 1.1.1-rc.1 — 2022-09-15
- 1.1.1-rc.0 — 2022-09-15
- 1.1.0 — 2022-07-20
- … 100 more at https://npm.io/package/@mycujoo/player-core/versions

## README

# Player core

Based on video.js project

## Dependencies

This project's advanced features and some of the core features will require these packages to be used in your project:

```
react
react-dom
@emotion/react
prop-types
lodash
```

## Usage

To use Player core in a React project, all you need is to install this package:

```
yarn add @mycujoo/player-react
```

The minimal setup will look like this:

```
import Player from '@mycujoo/player-core'
....
// render method of your component
<Player source="path-to-file" />
```

## API

| Prop            |   Type   | Description                                                                            |
| --------------- | :------: | -------------------------------------------------------------------------------------- |
| source          |  string  | Path to `m3u8` or `mp4` video source, required                                         |
| autoplay        |   bool   | html5 video tag autoplay attribute                                                     |
| controls        |   bool   | html5 video tag constrols attribute                                                    |
| playsInline     |   bool   | html5 video tag playsInline attribute                                                  |
| qualitySelector |   bool   | Determines if quality selector should be used or not                                   |
| debug           |   bool   | Toggles debug mode, if it is on video.js                                               |
| onError         | function | Is triggered when video.js throws an error, see vjs errors documentation for more info |
| onClick         | function | Is triggered when clicking on the player wrapper                                       |
| onPlayerActive  | function | Is triggered when video is playing every 5 seconds to report healthy playback          |
| onVideoPlay     | function | Is triggered on html5 video tag `play` event                                           |
| onVideoPause    | function | Is triggered on html5 video tag `pause` event                                          |
| onVideoSeek     | function | Is triggered on html5 video tag `seek` event                                           |
| onVideoStart    | function | Is triggered on first occurence of html5 video tag `play` event                        |
| onVideoEnd      | function | Is triggered on html5 video tag `end` event                                            |
| onVideoJsInit   | function | Is triggered after video.js class is instantiated. The instance is passed as a param   |

Additionaly the library also exports some videojs generic components that can be used as follows:

```
import Player, { CustomFullScreenButton, TotalViewers, WatchOnLink } '@mycujoo/player-core'
(props) => {
    const [playerInstance, setPlayerInstance] = useState(null)
    const { totalViewers, isLive } = props

    <Player {...props} onVideoJsInit={instance => setPlayerInstance(instance)}>
        <TotalViewers
            player={playerInstance}
            label=""
            totalViewers={totalViewers}
            show={isLive}
        />
        <CustomFullScreenButton
            player={playerInstance}
            setFullscreen={isFS => console.log(`Player is ${isFS? 'fullscreen' : 'inline'}`)}
        />
        <WatchOnLink
            player={playerInstance}
            url='//external.url.link'
            target = '_blank' // default
            logo = '//logo.url',
            title = 'Watch on MLS',
        />
    </Player>
}

```

## Development

To set up development environment for this project you will need to link player package inside you project, but also link all peer dependencies from you project inside player.

So the steps are following:

1. Run yarn link inside @mycujoo/player-core repository
2. Go to your project root and run `yarn link @mycujoo/player-core`
3. Go to each of the dependeincy package inside your project's `node_modules` and run yarn link
4. Go to @mycujoo/player-core repository again and run `yarn link react react-dom @emotion/react prop-types lodash`

To speed up the build, make sure that terser and visualizer are disabled in rollupConfig, development config would be created in the future.

To deploy new version to npm:
Make sure the version in `package.json` is updated, then create new tag with version format and push it to the repo:

```
git tag v1.0.50 -am 'version 50 message'
git push origin v1.0.50
```

This will trigger a job in CircleCI that will run `npm publish` and push the changes to npm.
Alternatively you can just update the version in `package.json` and then run `npm publish` to publish the bundle.

## Tests

Run `yarn test` to run tests.

---
_Source: https://npm.io/package/@mycujoo/player-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
