Skip to main content

Media Data Provider

Media player data transfer between iCUE and HTML widgets: currently playing track information and playback controls.

Overview

  • Module name: widgetbuilder.mediadataprovider
  • Plugin name: Media
  • Version: 1.0

Manifest entry:

"required_plugins": [
  "widgetbuilder.mediadataprovider:Media:1.0"
]

Properties

PropertyTypeDescription
songNamestringCurrent song name
artiststringCurrent artist name

Methods

getSongName(requestId)

Gets the current song name asynchronously.

ParameterTypeDescription
requestIdintRequest ID for correlation

Response: string

getArtist(requestId)

Gets the current artist name asynchronously.

ParameterTypeDescription
requestIdintRequest ID for correlation

Response: string

triggerPlayPause()

Toggles play/pause state.

triggerNextTrack()

Skips to the next track.

triggerPreviousTrack()

Returns to the previous track.

Signals

asyncResponse(requestId, value)

Emitted when an async method completes.

ParameterTypeDescription
requestIdintOriginal request ID
valuevarResponse value

SimpleMediaApiWrapper

Promise-based wrapper for the Media plugin.

Location: <<iCUE install dir>>/widgets/common/plugins/SimpleMediaApiWrapper.js

Initialization

const api = new SimpleMediaApiWrapper(window.plugins.Mediadataprovider);
ParameterTypeDefaultDescription
window.plugins.Mediadataproviderobject-Plugin instance

Methods

getSongName()

Returns Promise<string> with the current song name.

getArtist()

Returns Promise<string> with the current artist name.

Example

manifest.json

"required_plugins": [
  "widgetbuilder.mediadataprovider:Media:1.0"
]

index.html

// <script src="common/plugins/IcueWidgetApiWrapper.js"></script>
// <script src="common/plugins/SimpleMediaApiWrapper.js"></script>

const mediaApi = new SimpleMediaApiWrapper(window.plugins.Mediadataprovider);

async function displayCurrentTrack() {
    const [songName, artist] = await Promise.all([
        mediaApi.getSongName(),
        mediaApi.getArtist(),
    ]);
    console.log(`Now playing: ${songName} by ${artist}`);
}

// Playback controls
window.plugins.Mediadataprovider.triggerPlayPause();
window.plugins.Mediadataprovider.triggerNextTrack();
window.plugins.Mediadataprovider.triggerPreviousTrack();

IcueWidgetApiWrapper and SimpleMediaApiWrapper are available in the <<iCUE install dir>>/widgets/common/plugins directory.