Labs/Jetpack/JEP/26: Difference between revisions
No edit summary |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
=== Introduction === | === Introduction === | ||
This module allows the developer to access the host media player (currently, iTunes on Mac; players supporting [http://wiki.xmms2.xmms.se/wiki/Media_Player_Interfaces dbus] on Linux; no support for Windows as of yet). The developer may query the media player for | This module allows the developer to access the host media player (currently, iTunes on Mac; players supporting [http://wiki.xmms2.xmms.se/wiki/Media_Player_Interfaces 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 === | === API === | ||
The Music module | The Music module is available under <code>jetpack.music</code>. | ||
To search for a track, album or artist, call: <code>jetpack.music.search(term)</code>. An array of <tt>IMusicTrack</tt> objects will be returned. Each object contains the <tt>artist</tt>, <tt>album</tt> and <tt>title</tt> properties. | To search for a track, album or artist, call: <code>jetpack.music.search(term)</code>. An array of <tt>IMusicTrack</tt> objects will be returned. Each object contains the <tt>artist</tt>, <tt>album</tt> and <tt>title</tt> properties. | ||
Line 21: | Line 21: | ||
Other methods available are <code>play()</code>, <code>pause()</code>, <code>stop()</code>, <code>gotoNextTrack()</code>, and <code>gotoPreviousTrack()</code>. | Other methods available are <code>play()</code>, <code>pause()</code>, <code>stop()</code>, <code>gotoNextTrack()</code>, and <code>gotoPreviousTrack()</code>. | ||
=== Example === | |||
This jetpack will play your favorite track everytime Firefox starts. | |||
<pre class="brush:js;toolbar:false;"> | |||
jetpack.future.import('music'); | |||
let tracks = jetpack.music.search('thriller'); | |||
jetpack.music.playTrack(tracks[0]); | |||
</pre> |
Latest revision as of 23:44, 10 September 2009
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]);