← Back to team overview

nuvola-player-devel team mailing list archive

Nuvola Player JavaScript API 2.1

 

Dear friends,

Nuvola Player 2.1.0 will bring JavaScript API 2.1. This API has
already landed in the trunk branch and is available in recent builds
from Nuvola Player Unstable Builds PPA for Ubuntu.

Backward Compatibility
=================

JS API 2.1 is backward compatible with JS API 2.0, i.e. no changes to
current service integrations are needed. Service integrations
dependent on API 2.1 must have api_major = 2 and api_minor = 1 in
metadata.conf.

What's New
=========

Major change is a method for injection of JavaScript API to other
frames/iframes. Sample code snippet:

----------------------------------
(function(Nuvola){

var PLAYER_FRAME_ID = "playerframe";

if (Nuvola.frame_id == Nuvola.MAIN_FRAME_ID)
{
    // We are in the main frame, but playback occurs in other frame.
    var result = Nuvola.injectToFrame(PLAYER_FRAME_ID);
    if (result !== true)
        throw new Error("Injection to frame " + PLAYER_FRAME_ID + " failed.");
}
else if (Nuvola.frame_id == PLAYER_FRAME_ID)
{
    // We are in player's frame, so we can retrieve
    // information about the current song.
    Nuvola.updateSong(
    playerapi.song,
    playerapi.artist,
    playerapi.album,
    null,
    Nuvola.STATE_PLAYING);
}

})(this);
----------------------------------

Documentation
===========

Documentation of the new API is available in developer's news for NP 2.1.0 [1].

[1] http://nuvolaplayer.fenryxo.cz/releases/2.1/developers.html


Best regards,

Jiří Janoušek