libtizplex

group libtizplex

library

A C library to access audio from a Plex server.

Typedefs

typedef struct tiz_plex tiz_plex_t

The plex opaque structure

typedef enum tiz_plex_playback_mode tiz_plex_playback_mode_t

Various playback modes that control the playback queue.

Enums

enum tiz_plex_playback_mode

Various playback modes that control the playback queue.

Values:

enumerator ETIZPlexPlaybackModeNormal
enumerator ETIZPlexPlaybackModeShuffle
enumerator ETIZPlexPlaybackModeMax

Functions

int tiz_plex_init(tiz_plex_ptr_t *app_plex, const char *ap_base_url, const char *ap_auth_token, const char *ap_music_section)

Initialize the tiz_plex handle.

Return

0 on success.

Parameters
  • app_plex: A pointer to the tiz_plex handle which will be initialised.

  • ap_base_url: The Plex server base url.

  • ap_auth_token: The Plex account auth token.

  • ap_music_section: The name of the music section in the Plex library.

void tiz_plex_clear_queue(tiz_plex_t *ap_plex)

Clear the playback queue.

Parameters
  • ap_plex: The tiz_plex handle.

void tiz_plex_print_queue(tiz_plex_t *ap_plex)

Print to standard output the contents of the playback queue.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_index(tiz_plex_t *ap_plex)

Retrieve the index in the playback queue of the stream currently selected.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_queue_length(tiz_plex_t *ap_plex)

Retrieve the current length of playback queue.

Parameters
  • ap_plex: The tiz_plex handle.

int tiz_plex_get_current_queue_length_as_int(tiz_plex_t *ap_plex)

Retrieve the current length of the playback queue as integer.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_queue_progress(tiz_plex_t *ap_plex)

Retrieve the current queue progress (e.g. ‘5 of 17’, where 5 is the current stream index, and 17 is the total streams in the queue).

Parameters
  • ap_plex: The tiz_plex handle.

void tiz_plex_set_playback_mode(tiz_plex_t *ap_plex, const tiz_plex_playback_mode_t a_mode)

Set the playback mode (normal, shuffle).

Parameters
  • ap_plex: The tiz_plex handle.

  • a_mode: The playback mode (e.g. normal, shuffle)

int tiz_plex_play_audio_tracks(tiz_plex_t *ap_plex, const char *ap_track_name)

Add a Plex audio stream to the playback queue.

After calling this method, the various tiz_plex_get* methods can be used to interact with the playback queue.

Return

0 on success

Parameters
  • ap_plex: The tiz_plex handle.

  • ap_track_name: An search term.

int tiz_plex_play_audio_artist(tiz_plex_t *ap_plex, const char *ap_artist_name)

Add a Plex audio stream to the playback queue.

After calling this method, the various tiz_plex_get* methods can be used to interact with the playback queue.

Return

0 on success

Parameters
  • ap_plex: The tiz_plex handle.

  • ap_artist_name: An search term.

int tiz_plex_play_audio_album(tiz_plex_t *ap_plex, const char *ap_album)

Add all the audio streams of a Plex playlist to the playback queue.

After calling this method, the various tiz_plex_get* methods can be used to interact with the playback queue.

Return

0 on success

Parameters
  • ap_plex: The tiz_plex handle.

  • ap_album: A playlist full url or playlist id.

int tiz_plex_play_audio_playlist(tiz_plex_t *ap_plex, const char *ap_playlist)

Add all the audio streams of a Plex playlist to the playback queue.

After calling this method, the various tiz_plex_get* methods can be used to interact with the playback queue.

Return

0 on success

Parameters
  • ap_plex: The tiz_plex handle.

  • ap_playlist: A playlist full url or playlist id.

const char *tiz_plex_get_url(tiz_plex_t *ap_plex, const int a_position)

Retrieve the stream url as the specified position in the play queue.

On success, the playback queue pointer moves to the position indicated.

Return

The specified url in the playback queue or NULL if the playback queue is empty or the the specified position is out of range.

Parameters
  • ap_plex: The tiz_plex handle.

  • a_position: A position value in the range [1, len(queue)].

const char *tiz_plex_get_next_url(tiz_plex_t *ap_plex, const bool a_remove_current_url)

Retrieve the next stream url

The playback queue pointer moves one position forwards.

Return

The next url in the playback queue or NULL if the playback queue is empty.

Parameters
  • ap_plex: The tiz_plex handle.

  • a_remove_current_url: If true, delete the current url from the playback queue before moving to the next url.

const char *tiz_plex_get_prev_url(tiz_plex_t *ap_plex, const bool a_remove_current_url)

Retrieve the previous stream url.

The playback queue pointer moves one position backwards.

Return

The previous url in the playback queue or NULL if the playback queue is empty.

Parameters
  • ap_plex: The tiz_plex handle.

  • a_remove_current_url: If true, delete the current url from the playback queue before moving to the previous url.

const char *tiz_plex_get_current_audio_track_title(tiz_plex_t *ap_plex)

Retrieve the current audio track’s title.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_artist(tiz_plex_t *ap_plex)

Retrieve the current audio track’s artist.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_album(tiz_plex_t *ap_plex)

Retrieve the current audio track’s album.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_year(tiz_plex_t *ap_plex)

Retrieve the current audio track’s publication year.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_file_size(tiz_plex_t *ap_plex)

Retrieve the current audio track’s file size.

Parameters
  • ap_plex: The tiz_plex handle.

int tiz_plex_get_current_audio_track_file_size_as_int(tiz_plex_t *ap_plex)

Retrieve the current audio track’s file size (as int).

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_duration(tiz_plex_t *ap_plex)

Retrieve the current audio track’s duration.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_bitrate(tiz_plex_t *ap_plex)

Retrieve the current audio track’s bitrate.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_codec(tiz_plex_t *ap_plex)

Retrieve the current audio track’s codec id.

Parameters
  • ap_plex: The tiz_plex handle.

const char *tiz_plex_get_current_audio_track_album_art(tiz_plex_t *ap_plex)

Retrieve the current track’s album art.

Parameters
  • ap_plex: The plex handle.

void tiz_plex_destroy(tiz_plex_t *ap_plex)

Destroy the tiz_plex handle.

Parameters
  • ap_plex: The tiz_plex handle.