---
name: "njb_playapi"
section: "3"
platform: "linux"
package: "libnjb-doc"
version: "2.2.5-4.3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/njb_playapi"
---

# njb\_playapi(3)

## NAME

The track playback (listening) API -

### Functions

int **NJB\_Play\_Track** (**njb\_t** \*njb, u\_int32\_t trackid)\
 int **NJB\_Queue\_Track** (**njb\_t** \*njb, u\_int32\_t trackid)\
 int **NJB\_Stop\_Play** (**njb\_t** \*njb)\
 int **NJB\_Pause\_Play** (**njb\_t** \*njb)\
 int **NJB\_Resume\_Play** (**njb\_t** \*njb)\
 int **NJB\_Seek\_Track** (**njb\_t** \*njb, u\_int32\_t position)\
 int **NJB\_Elapsed\_Time** (**njb\_t** \*njb, u\_int16\_t \*elapsed, int \*change)\

## Function Documentation

### int NJB\_Elapsed\_Time (njb\_t \* njb, u\_int16\_t \* elapsed, int \* change) This function returns the elapsed time for the currently playing track on the device. Additionally, it signals if the track has changed, e.g. if the device has skipped to the next track in the queue.

Currently, it may only be determined if the currently playing track in the Nomad's play queue has changed (or ended) from a previous call to NJB\_Elapsed\_Time, because the indicator is that the elapsed time goes from a greater number to a lower number. Typically, when the first (zeroth) track in the play queue ends, the elapsed time is set to zero, and the change bit is set. However, if the zeroth track is the only track on the play queue, it must be more than 1 second long and NJB\_Elapsed\_Time must have been called at least once after 1 second actually has elapsed to register the change (song end) on a subsequent call to NJB\_Elapsed\_Time.

NOTE, the elapsed time will NOT always be zero when the change bit is set, as a call to NJB\_Elapsed\_Time may arrive late after a song has started.

NOTE, after NJB\_Play\_Track is called an immediate call NJB\_Elapsed\_Time will not indicate change, even if there was a track playing previously.

Obviously, this notification of change scheme is a flawed one, and some Nomad play queue management functions, such as finding out the actual trackid playing on the Nomad would be favored over this approach. One should not really rely too heavily on this approach.

**Parameters:**

*njb* a pointer to the jukebox object that the track is playing on. \
 *elapsed* a pointer to a variable that will hold the number of elapsed seconds after the call to this function. \
 *change* a pointer to a variable that will hold 0 if the track has not changed, and something different from 0 if the track has changed.

**Returns:**

0 on success, -1 on failure.

**Examples:**  **cursesplay.c**, and **play.c**.

References njb\_struct::device\_type, and NJB\_DEVICE\_NJB1.

### int NJB\_Pause\_Play (njb\_t \* njb) This pauses the current playback of a track on the device.

**Parameters:**

*njb* a pointer to the jukebox object to play the track on.

**Returns:**

0 on success, -1 on failure.

**See also:**

**NJB\_Resume\_Play()**

**NJB\_Stop\_Play()**

**Examples:**  **cursesplay.c**.

### int NJB\_Play\_Track (njb\_t \* njb, u\_int32\_t trackid) This starts playing a certain track on the device. This command will implicitly clear any pending or playing playback queue. You may queue up other songs using NJB\_Queue\_Track() while the first track is playing. The track on which you called NJB\_Play\_Track() will implicitly be placed first in the queue.

**Parameters:**

*njb* a pointer to the jukebox object to play the track on. \
 *trackid* the track to play.

**Returns:**

0 on success, -1 on failure.

**See also:**

**NJB\_Queue\_Track()**

**NJB\_Stop\_Play()**

**NJB\_Pause\_Play()**

**NJB\_Seek\_Track()**

**NJB\_Elapsed\_Time()**

**Examples:**  **cursesplay.c**, and **play.c**.

References njb\_struct::device\_type, NJB\_DEVICE\_NJB1, and njb\_verify\_last\_command().

### int NJB\_Queue\_Track (njb\_t \* njb, u\_int32\_t trackid) This adds a track to the play queue of a device.

**Parameters:**

*njb* a pointer to the jukebox object to play the track on. \
 *trackid* the track to add to the queue.

**Returns:**

0 on success, -1 on failure.

**Examples:**  **cursesplay.c**, and **play.c**.

References njb\_struct::device\_type, NJB\_DEVICE\_NJB1, and njb\_verify\_last\_command().

### int NJB\_Resume\_Play (njb\_t \* njb) This resumes play of a track on the device after pause.

**Parameters:**

*njb* a pointer to the jukebox object to resume the track on.

**Returns:**

0 on success, -1 on failure.

**See also:**

**NJB\_Pause\_Play()**

**Examples:**  **cursesplay.c**.

### int NJB\_Seek\_Track (njb\_t \* njb, u\_int32\_t position) This seeks into an offset of the currenly playing track on the device. You can skip to an offset forward/backward in the currently playing file, given as milliseconds.

**Parameters:**

*njb* a pointer to the jukebox object to stop the current playing track on. \
 *position* the position in the track file given as milliseconds. Offsets larger than the file length should not be used.

**Returns:**

0 on success, -1 on failure.

**Examples:**  **cursesplay.c**.

### int NJB\_Stop\_Play (njb\_t \* njb) This stops playback of a track on the device.

**Parameters:**

*njb* a pointer to the jukebox object to stop the current playing track on.

**Returns:**

0 on success, -1 on failure.

**See also:**

**NJB\_Pause\_Play()**

**Examples:**  **cursesplay.c**, and **play.c**.

References njb\_struct::device\_type, and NJB\_DEVICE\_NJB1.

## Author

Generated automatically by Doxygen for libnjb from the source code.
