2.0.1-creds-test.1 • Published 1 year ago

joshaorchestrajs v2.0.1-creds-test.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Orchestra

Orchestra is a Javascript library built for Amazon Music teams who want to build a playback experience on the Web. Orchestra is a wrapper around Maestro and MusicServices(https://code.amazon.com/packages/NodeJS-MusicServices/trees/mainline. It simplifies the utilisation of Maestro and encapsulate all the service calls.

This document explains why Orchestra was created and which pain points it's trying to solve.

Getting Started

Installation

Orchestra uses the npm-pretty-much build system.

Step 1 Add Orchestra to your Config file.

dependencies = {
        1.0 = {
            Orchestrajs = 2.0;
        };
     };

Example: https://code.amazon.com/packages/DMWebPlayerSkyfire/blobs/1421d8f914057d8b4282243b81fdb74453cde1bb/--/Config#L26

Step 2 Add Orchestra to your package.json

"dependencies": {
        "@amzn/Orchestrajs": "2.0.0"
}

Example: https://code.amazon.com/packages/DMWebPlayerSkyfire/blobs/d15cf359e640efae063057a1b9717ddd399a38da/--/package.json#L36

Step 3

You are now able to import the Orchestra library in your source code assuming you have a build system (ex: webpack ,rollup).

Example: https://code.amazon.com/packages/DMWebPlayerSkyfire/blobs/d8d3e25db72c2fec1080662ca97cea2ad85f8d49/--/src/player/index.ts#L31

Usage

Orchestra shares the same public API as the Maestro Player therefore it's recommended to understand how Maestro works before using Orchestra.

Orchestra extends the Maestro contructor and play method.

Example

import Orchestra from ('@amzn/Orchestrajs');

const configuration = {
            appVersion: '1.0.201672.0', // required
            hostname: window.location.hostname, // required
            deviceTypeId: 'A9AIM1JKFYHZW', // required
            musicTerritory: 'US', // required
            clientId: 'WebCP', // required
            customerId: 'A', // required
            deviceId: 'B' // required
            flags: { // optional
                metrics: false,
                drm: true
            },
            crossDomain: true, // optional
            withCredentials: true, // optional
};
const player = new Orchestra.Player(configuration);
player.load('asin://ASIN');
player.play('asin:/ASIN');

If you are looking for a production application using Orchestra, you can look at DMWebPlayerSkyfire

Constructor

The constructor expects a configuration object argument in order to be able to call Music Services.

import Orchestra from ('@amzn/Orchestrajs');
const configuration = {
            appVersion: '1.0.201672.0', // required
            hostname: window.location.hostname, // required
            deviceTypeId: 'A9AIM1JKFYHZW', // required
            musicTerritory: 'US', // required
            clientId: 'WebCP', // required
            customerId: 'A', // required
            deviceId: 'B' // required
};
const player = new Orchestra.Player(configuration);

Load

load now required a prefix identifier (in contrast to Maestro). The prefix helps Orchestra determine which service it should call.

The supported prefixes are the following:

  • https://
  • asin://
  • coid://
  • livemcid://
player.load('asin://ASIN');
player.load('https://cloudfront.com/file.mp3');
player.load('coid://31bc7dc9-cfaa-4d22-a749-505c31afb3e5');