Skip to content

Commit

Permalink
fix doc (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1ller0 authored Mar 6, 2021
1 parent cb37c26 commit 1112ceb
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ const myAwesomeStation = new Station({
```

## Station methods
### Public methods that should be exposed to users
`connectListener` connects real users to your station
`connectListener` connects real users to your station, this is the only method that should be exposed to listeners
response argument is required
```javascript
station.connectListener(request, response, callback);
```
### Private methods that should be used only by admins
`addFolder` adds track within a folder to the playlist
```javascript
station.addFolder('User/Music');
Expand All @@ -72,6 +70,28 @@ station.next();
```javascript
station.getPlaylist();
```
`reorderPlaylist` lets you manipulate the entire playlist via passed callback
```javascript
const myShuffleMethod = (list) => list
// doubles the list (making it twice as long)
.concat(list)
// filters out the specific track
.filter(track => track.fsStats.name !== 'Artist - Track');

station.reorderPlaylist(myShuffleMethod);
```
There are also some built-in shuffle methods
```javascript
const { SHUFFLE_METHODS } = require('@fridgefm/radio-core')

// This one randomly shuffles the playlist (keeping the length the same)
station.reorderPlaylist(SHUFFLE_METHODS.randomShuffle());

// This one moves the track on the 1st position and moves it to the 2nd position
station.reorderPlaylist(SHUFFLE_METHODS.rearrange({ from: 1, to: 2 }));

```
`on` lets you make a subscription to station events (see below)

## Station events
Station emits several events - they are available via
Expand Down Expand Up @@ -107,17 +127,25 @@ Event fires when there is some error. You `should` add this handler - otherwise
station.on(PUBLIC_EVENTS.ERROR, (e) => { handleError(e) });
```

## or just go to [examples](./examples/server.js)
> or just go to [examples](./examples/server.js)
## Development
```
yarn build
node examples/server.js
```
OR
or
```
yarn build
node examples/server.js [path/to/your_mp3tracks]
# in this case it would take a little more time, just wait
```
There is also a watch mode - you need two tabs in a terminal
```
yarn watch
```
```
node examples/server.js [path/to/your_mp3tracks]
```

## Demo
Fully working demo is available on https://fridgefm.com

0 comments on commit 1112ceb

Please sign in to comment.