3.2.0 • Published 11 months ago

volume-player-sdk v3.2.0

Weekly downloads
44
License
ISC
Repository
github
Last release
11 months ago

volume-player-sdk

Installation

npm install volume-player-sdk

Else with Yarn

yarn add volume-player-sdk

Usage

import { playPlaylist } from 'volume-player-sdk';

playPlaylist({
  slug: 'foobar'
});

Functions Available

Media Controls

import {
  PLAYLIST_TYPE_HD,
  PLAYLIST_TYPE_4K,
  PLAYLIST_TYPE_UHD,
  getVolumeLevel,
  isMuted,
  mute,
  playPlaylist,
  print,
  reboot,
  reload,
  resetVolume,
  resizeVideo,
  send,
  setDrawerButtonSettings
  setSetting,
  sizeDefault,
  skipTrack,
  stopPlaylist,
  sync,
  unmute,
  volumeDown,
  volumeSet,
  volumeUp,
} from 'volume-player-sdk';

playPlaylist({
  slug: 'foobar'
});

// To play the HD version of the playlist
playPlaylist({
  slug: 'foobar',
  type: PLAYLIST_TYPE_HD,
});

print('https://file/to/print.pdf');

stopPlaylist();

resizeVideo({
    width: 100,                 // width percent
    height: 100,                // height percent
    anchorHorizontal: 'right',  // horizontal anchor ('left' and 'centre' are the other options)
    anchorVertical: 'bottom',   // verticle anchor ('top' and 'centre' are the other options)
    paddingTop: 0,              // padding for the top
    paddingBottom: 0,           // padding for the bottom
    paddingLeft: 0,             // padding for the left
    paddingRight: 0,            // padding for the right
});

skipTrack();

setDrawerButtonSettings(x, y, width, height);

setSetting({
  key: "layer_extra",
  value: JSON.stringify({"foo": "bar"}),
});

sync({
  my: "syncing",
  data: ["object"]
});

sizeDefault();,

send({ bin: "baz" });

reboot(); // it reboots the device

reload(); // reload the layer

volumeUp({ step: 2 }); // turn volume up two levels on the player (Not CEC) - step is optional, defaults to 1
volumeDown({ step: 2 }); // turn volume down two levels on the player (Not CEC) - step is optional, defaults to 1

volumeSet({
  level: 5
});

const volumeLevel = getVolumeLevel(); 

resetVolume();


const isTheSoundOn = !isMuted();


mute(); // mutes the device (Not CEC)
unmute(); // unmutes the device (Not CEC)

CEC Commands

CEC Commands need to be queued else there is the risk of commands being ommitted if they are sent too quickly.

import { CEC: { start, CEC_DESTINATION_TV, volumeUp } } from 'volume-player-sdk';

start();
volumeUp(CEC_DESTINATION_TV);
Other CEC functions
import {
  CEC: {
    CEC_DESTINATION_TV,
    CEC_DESTINATION_SOUND_BAR,
    start,
    stop,
    volumeUp,
    volumeDown,
    volumeMute,
    getVolumeLevel,
    reset,
    isMuted,
    mute,
    unmute,
    standby,
    switchAudioToTv,
    switchAudioToSoundbar,    
  }
} from 'volume-player-sdk';

start();

volumeUp({ destination: CEC_DESTINATION_SOUND_BAR, step: 3 });
volumeDown({ destination: CEC_DESTINATION_SOUND_BAR, step: 3 });

reset({
  destination: CEC_DESTINATION_SOUND_BAR,
  level: 5,
  maxLevel: 10,
});

volumeMute({ destination: CEC_DESTINATION_SOUND_BAR });
volumeUnMute({ destination: CEC_DESTINATION_SOUND_BAR });

isMuted({
  destination: CEC_DESTINATION_SOUND_BAR,
  callback: (booleanValue) => console.log(booleanValue),
});

getVolumeLevel({
  destination: CEC_DESTINATION_SOUND_BAR,
  callback: (integer) => console.log(integer),
});

standby({ destination: CEC_DESTINATION_SOUND_BAR });

stop();

switchAudioToTv()

switchAudioToSoundbar()

Device Events

Volume players sends events to the layer by calling a function called deviceEvent, if declared in thewindow object:

type CustomEvent = DeviceEvent<'foo', { a: number }>

window.deviceEvent = (data: DeviceEventData | CustomEvent) => {
  const { actionType, actionDetails } = data
  if (actionType === 'startVideo') {
    // actionDetails here is type VideoDetails
    actionDetails.length
  }
  if (actionType === 'foo') {
    // a property here is type number, as declared before
    actionDetails.a
  }
}
3.2.0

11 months ago

3.0.0

1 year ago

3.1.0

11 months ago

2.0.7

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.6

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.14.0

3 years ago

1.13.13

3 years ago

1.13.12

3 years ago

1.13.6

4 years ago

1.13.5

4 years ago

1.13.4

4 years ago

1.13.9

4 years ago

1.13.11

4 years ago

1.13.8

4 years ago

1.13.10

4 years ago

1.13.7

4 years ago

1.13.2

4 years ago

1.13.1

4 years ago

1.13.0

4 years ago

1.13.3

4 years ago

1.12.0

4 years ago

1.11.4

4 years ago

1.11.3

4 years ago

1.11.2

4 years ago

1.11.1

4 years ago

1.11.0

4 years ago

1.10.3

4 years ago

1.9.1

4 years ago

1.9.0

4 years ago

1.9.2

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.8.6

5 years ago

1.8.5

5 years ago

1.8.4

5 years ago

1.8.3

5 years ago

1.8.2

5 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.10

6 years ago

1.4.9

6 years ago

1.4.8

6 years ago

1.4.7

6 years ago

1.4.6

6 years ago

1.4.5

6 years ago

1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago