Alexa multimedia instrumentation

Marfeel tracks audio reproduction in Alexa integrating with Alexa Custom Skills running in node environments.

Installation

In order to install the package via npm, your .npmrc file should contain:

@marfeel:registry=https://repositories-proxy.mrf.io/nexus/repository/npm-all

To install the package, run npm install @marfeel/compasstrackermultimedia-alexa. If you are using Alexa developer console for building your skill, add the following entry in the package.json dependencies definition:

"dependencies": {
    "@marfeel/compasstrackermultimedia-alexa": "^1.0.0-snapshot.22",
},

Usage

@marfeel/compasstrackermultimedia-alexa package integrates with your skill via interceptors.

const Alexa = require('ask-sdk-core');
const { getInterceptors } = require('@marfeel/compasstrackermultimedia-alexa');

const YOUR_ACCOUNT_ID = 0;
const { requestInterceptor, responseInterceptor } = getInterceptors({ accountId: YOUR_ACCOUNT_ID });


const skillBuilder = Alexa.SkillBuilders.custom();

exports.handler = skillBuilder
	.addRequestHandlers(
		// your handlers
	)
	.addResponseInterceptors(responseInterceptor)
	.addRequestInterceptors(requestInterceptor)
	.lambda();

Unique Media Identifier

The token generated for AudioPlayer is used as the media unique identifier. Different users listening the same resource should receive the same token. However, you can change this behavior with a translator getInterceptors function :

const Alexa = require('ask-sdk-core');
const { getInterceptors } = require('@marfeel/compasstrackermultimedia-alexa');

const YOUR_ACCOUNT_ID = 0;
const { requestInterceptor, responseInterceptor } = getInterceptors({ 
    accountId: YOUR_ACCOUNT_ID,
    translator: yourToken => {
        // your logic for retrieving the resource id from yourToken
        return resourceId; 
    } 
});

Media Title

Media title is retrieved from AudioPlayer.Play metadata directive. By default, audioItem.metadata.title is used. If your metadata title is not the name you want to use for your media tracking, you can use mrfTitle:

addAudioPlayerPlayDirective('REPLACE_ALL', stream.url, stream.token, 0, null, {
{
      'title': 'Title to display in alexa',
      'subtitle': 'Subtitle',
      'mrfTitle': `media-name`,
      'art': {},
      'backgroundImage': {},
});