Labs/Jetpack/JEP/26

From MozillaWiki
< Labs‎ | Jetpack‎ | JEP
Jump to: navigation, search

JEP 26 - Music

  • Champion: Anant Narayanan <anant at mozilla dot com>
  • Status: Implementing
  • Type: API Track
  • Created: 10 September 2009
  • Reference Implementation: jetpack.future.import("music")
  • JEP Index

Introduction

This module allows the developer to access the host media player (currently, iTunes on Mac; players supporting dbus on Linux; no support for Windows as of yet). The developer may query the media player for tracks, play or pause them, and perform other functions such as skip track and go to previous track.

API

The Music module is available under jetpack.music.

To search for a track, album or artist, call: jetpack.music.search(term). An array of IMusicTrack objects will be returned. Each object contains the artist, album and title properties.

You may pass a IMusicTrack object to jetpack.music.playTrack(obj) in order to play that track. jetpack.music.getCurrentTrack() returns the track currently playing.

Other methods available are play(), pause(), stop(), gotoNextTrack(), and gotoPreviousTrack().

Example

This jetpack will play your favorite track everytime Firefox starts.

jetpack.future.import('music');
let tracks = jetpack.music.search('thriller');
jetpack.music.playTrack(tracks[0]);