volume-player-sdk

`npm install volume-player-sdk`

Usage no npm install needed!

<script type="module">
  import volumePlayerSdk from 'https://cdn.skypack.dev/volume-player-sdk';
</script>

README

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,
  playPlaylist,
  stopPlaylist,
  skipTrack,
  setSetting,
  resizeVideo,
  openCameraApplication,
  sizeDefault,
  send,
  sync,
  reload,
  volumeUp,
  volumeDown,
  volumeSet,
  getVolumeLevel,
  resetVolume,
  isMuted,
  mute,
  unmute,
} from 'volume-player-sdk';

playPlaylist({
  slug: 'foobar'
});

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

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();

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

openCameraApplication();

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

sizeDefault();,

send({ bin: "baz" });

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
    
  }
} 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();