1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
|
// SPDX-License-Identifier: BSD-2-Clause
// Copyright The Music Player Daemon Project
/*! \file
* \brief MPD client library
*
* Controlling playback.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_PLAYER_H
#define MPD_PLAYER_H
#include "compiler.h"
#include "status.h"
#include <stdbool.h>
struct mpd_connection;
struct mpd_song;
#ifdef __cplusplus
extern "C" {
#endif
/**
* There are two ways to address songs within the queue: by their position and
* by their id.
* The position is a 0-based index. It is unstable by design: if you move,
* delete or insert songs, all following indices will change, and a client can
* never be sure what song is behind a given index/position.
*
* Song ids on the other hand are stable: an id is assigned to a song when it
* is added, and will stay the same, no matter how much it is moved around.
* Adding the same song twice will assign different ids to them, and a
* deleted-and-readded song will have a new id. This way, a client can always
* be sure the correct song is being used.
*
* Many commands come in two flavors, one for each address type. Whenever
* possible, ids should be used.
*/
/**
* Fetches the currently selected song (the song referenced by
* mpd_status_get_song_id()).
* Call mpd_recv_song() to receive the response.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_current_song(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_current_song() and mpd_recv_song().
*
* @param connection the connection to MPD
* @return the current song, or NULL on error or if there is no
* current song
*/
mpd_malloc
struct mpd_song *
mpd_run_current_song(struct mpd_connection *connection);
/**
* Starts playing the current song from the beginning.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_play(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_play() and mpd_response_finish().
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_run_play(struct mpd_connection *connection);
/**
* Starts playing the specified song from the beginning.
*
* @param connection the connection to MPD
* @param song_pos the position of the song in the queue
* @return true on success, false on error
*/
bool
mpd_send_play_pos(struct mpd_connection *connection, unsigned song_pos);
/**
* Shortcut for mpd_send_play() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param song_pos the position of the song in the queue
* @return true on success, false on error
*/
bool
mpd_run_play_pos(struct mpd_connection *connection, unsigned song_pos);
/**
* Starts playing the specified song from the beginning.
*
* @param connection the connection to MPD
* @param song_id the id of the song
* @return true on success, false on error
*/
bool
mpd_send_play_id(struct mpd_connection *connection, unsigned song_id);
/**
* Shortcut for mpd_send_play_id() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param song_id the id of the song
* @return true on success, false on error
*/
bool
mpd_run_play_id(struct mpd_connection *connection, unsigned song_id);
/**
* Stops playing the current song.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_stop(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_stop() and mpd_response_finish().
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_run_stop(struct mpd_connection *connection);
/**
* This function uses a deprecated feature of MPD, you should avoid it.
*
* Toggles the pause mode by sending "pause" without arguments.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_toggle_pause(struct mpd_connection *connection);
/**
* This function uses a deprecated feature of MPD, you should avoid it.
* Shortcut for mpd_send_toggle_pause() and mpd_response_finish().
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_run_toggle_pause(struct mpd_connection *connection);
/**
* Pauses/Resumes playing the current song.
* If mode is true, MPD pauses the song; otherwise, MPD resumes the song.
*
* @param connection the connection to MPD
* @param mode if true: pause, if false: resume
* @return true on success, false on error
*/
bool
mpd_send_pause(struct mpd_connection *connection, bool mode);
/**
* Shortcut for mpd_send_pause() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param mode if true: pause, if false: resume
* @return true on success, false on error
*/
bool
mpd_run_pause(struct mpd_connection *connection, bool mode);
/**
* Play the next song in the playlist.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_next(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_next() and mpd_response_finish().
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_run_next(struct mpd_connection *connection);
/**
* Play the previous song in the playlist.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_previous(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_previous() and mpd_response_finish().
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_run_previous(struct mpd_connection *connection);
/**
* Seeks to the position t (in seconds) of position song_pos in the playlist.
*
* @param connection the connection to MPD
* @param song_pos the position of the song in the queue
* @param t the position within the song, in seconds
* @return true on success, false on error
*/
bool
mpd_send_seek_pos(struct mpd_connection *connection,
unsigned song_pos, unsigned t);
/**
* Shortcut for mpd_send_seek_pos() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param song_pos the position of the song in the queue
* @param t the position within the song, in seconds
* @return true on success, false on error
*/
bool
mpd_run_seek_pos(struct mpd_connection *connection,
unsigned song_pos, unsigned t);
/**
* Seeks to the position t (in seconds) of song id song_id.
*
* @param connection the connection to MPD
* @param song_id the id of the song
* @param t the position within the song, in seconds
* @return true on success, false on error
*/
bool
mpd_send_seek_id(struct mpd_connection *connection,
unsigned song_id, unsigned t);
/**
* Shortcut for mpd_send_seek_id() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param song_id the id of the song
* @param t the position within the song, in seconds
* @return true on success, false on error
*/
bool
mpd_run_seek_id(struct mpd_connection *connection,
unsigned song_id, unsigned t);
/**
* Seeks to the position t (in seconds; fractions allowed) of song id song_id.
*
* @param connection the connection to MPD
* @param song_id the id of the song
* @param t the position within the song, in seconds (fractions allowed)
* @return true on success, false on error
*/
bool
mpd_send_seek_id_float(struct mpd_connection *connection,
unsigned song_id, float t);
/**
* Shortcut for mpd_send_seek_id_float() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param song_id the id of the song
* @param t the position within the song, in seconds (fractions allowed)
* @return true on success, false on error
*/
bool
mpd_run_seek_id_float(struct mpd_connection *connection,
unsigned song_id, float t);
/**
* Seeks the current song.
*
* @param connection the connection to MPD
* @param t the position within the song, in seconds
* @param relative true makes #t a relative to the current position
* @return true on success, false on error
*
* @since MPD 0.17, libmpdclient 2.15
*/
bool
mpd_send_seek_current(struct mpd_connection *connection,
float t, bool relative);
/**
* Shortcut for mpd_send_seek_current() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param t the new position (in seconds)
* @param relative true to seek relative to the current position and
* false to seek to an absolute time stamp within the song
* @return true on success, false on error
*
* @since MPD 0.17, libmpdclient 2.15
*/
bool
mpd_run_seek_current(struct mpd_connection *connection,
float t, bool relative);
/**
* Sets repeat on/off for the current song.
* If mode is true, MPD repeats the song; otherwise, MPD does not repeat the
* song.
*
* @param connection the connection to MPD
* @param mode if true: repeat, if false: do not repeat
* @return true on success, false on error
*/
bool
mpd_send_repeat(struct mpd_connection *connection, bool mode);
/**
* Shortcut for mpd_send_repeat() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param mode if true: pause, if false: resume
* @return true on success, false on error
*/
bool
mpd_run_repeat(struct mpd_connection *connection, bool mode);
/**
* Sets random mode on/off for the queue.
* If mode is true, MPD enables random mode; otherwise, MPD disables random
* mode.
*
* @param connection the connection to MPD
* @param mode if true: enable random mode, if false: disable random mode
* @return true on success, false on error
*/
bool
mpd_send_random(struct mpd_connection *connection, bool mode);
/**
* Shortcut for mpd_send_random() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param mode if true: enable random mode, if false: disable random mode
* @return true on success, false on error
*/
bool
mpd_run_random(struct mpd_connection *connection, bool mode);
/**
* Sets single state for the playlist.
* If state is #MPD_SINGLE_ON, MPD enables single mode: playback is stopped
* after current song, or song is repeated if the repeat mode is enabled.
*
* If state is #MPD_SINGLE_OFF, MPD disables single mode: if random mode is
* enabled, the playlist order is shuffled after it is played completely.
*
* If state is #MPD_SINGLE_ONESHOT, MPD enables single mode temporarily: single
* mode is disabled (#MPD_SINGLE_OFF) after a song has been played and there is
* another song in the current playlist.
*
* @param connection the connection to MPD
* @param state the desired single mode state
* @return true on success, false on error or state is #MPD_SINGLE_UNKNOWN
*
* @since MPD 0.21, libmpdclient 2.18.
*/
bool
mpd_send_single_state(struct mpd_connection *connection,
enum mpd_single_state state);
/**
* Shortcut for mpd_send_single_state() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param state the desired single mode state
* @return true on success, false on error or state is #MPD_SINGLE_UNKNOWN
*
* @since MPD 0.21, libmpdclient 2.18.
*/
bool
mpd_run_single_state(struct mpd_connection *connection,
enum mpd_single_state state);
/**
* Sets single mode on/off for the playlist.
* This function does not support the 'oneshot' state for single mode: use
* mpd_send_single_state() instead.
*
* If mode is true, MPD enables single mode: playback is stopped after current
* song, or song is repeated if the repeat mode is enabled.
*
* If mode is false, MPD disables single mode: if random mode is enabled, the
* playlist order is shuffled after it is played completely.
*
* @param connection the connection to MPD
* @param mode if true: enable single mode, if false: disable single mode
* @return true on success, false on error
*
* @since MPD 0.15
*/
bool
mpd_send_single(struct mpd_connection *connection, bool mode);
/**
* Shortcut for mpd_send_single() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param mode if true: enable single mode, if false: disable single mode
* @return true on success, false on error
*
* @since MPD 0.15
*/
bool
mpd_run_single(struct mpd_connection *connection, bool mode);
/**
* Sets consume mode on/off for the playlist.
* If mode is true, MPD enables consume mode: each song played is removed from
* the playlist.
*
* This function does not support the 'oneshot' state for consume mode: use
* mpd_send_consume_state() instead.
*
* If mode is false, MPD disables consume mode.
*
* @param connection the connection to MPD
* @param mode if true: enable consume mode, if false: disable consume mode
* @return true on success, false on error
*
* @since MPD 0.15
*/
bool
mpd_send_consume(struct mpd_connection *connection, bool mode);
/**
* Shortcut for mpd_send_consume() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param mode if true: enable consume mode, if false: disable consume mode
* @return true on success, false on error
*
* @since MPD 0.15
*/
bool
mpd_run_consume(struct mpd_connection *connection, bool mode);
/**
* Sets consume state for the playlist.
* If state is #MPD_CONSUME_ON, MPD enables consume mode: each song played is removed from
* the playlist.
*
* If state is #MPD_CONSUME_OFF, MPD disables consume mode.
*
* If state is #MPD_CONSUME_ONESHOT, MPD enables consume mode temporarily: consume
* mode is disabled (#MPD_CONSUME_OFF) after a song has been played.
*
* @param connection the connection to MPD
* @param state the desired single mode state
* @return true on success, false on error or state is #MPD_SINGLE_UNKNOWN
*
* @since MPD 0.24, libmpdclient 2.21.
*/
bool
mpd_send_consume_state(struct mpd_connection *connection, enum mpd_consume_state state);
/**
* Shortcut for mpd_send_consume_state() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param state the desired single mode state
* @return true on success, false on error or state is #MPD_SINGLE_UNKNOWN
*
* @since MPD 0.24, libmpdclient 2.21.
*/
bool
mpd_run_consume_state(struct mpd_connection *connection, enum mpd_consume_state state);
/**
* Sets crossfading of seconds between songs on for the playlist.
* Crossfading only happens when the songs audio format are the same.
*
* @param connection the connection to MPD
* @param seconds seconds of crossfading between songs
* @return true on success, false on error
*/
bool
mpd_send_crossfade(struct mpd_connection *connection, unsigned seconds);
/**
* Shortcut for mpd_send_crossfade() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param seconds seconds of crossfading between songs
* @return true on success, false on error
*/
bool
mpd_run_crossfade(struct mpd_connection *connection, unsigned seconds);
/**
* Sets the threshold at which songs will be overlapped. Like crossfading but
* doesn't fade the track volume, just overlaps.
*
* The songs need to have MixRamp tags added by an external tool. 0dB is the
* normalized maximum volume; so use negative values (I prefer -17dB). In the
* absence of MixRamp tags, crossfading will be used.
*
* @param connection the connection to MPD
* @param db decibels of volume for overlapping songs
* @return true on success, false on error
*
* @since libmpdclient 2.2
*/
bool
mpd_send_mixrampdb(struct mpd_connection *connection, float db);
/**
* Shortcut for mpd_send_mixrampdb() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param db decibels of volume for overlapping songs
* @return true on success, false on error
*
* @since libmpdclient 2.2
*/
bool
mpd_run_mixrampdb(struct mpd_connection *connection, float db);
/**
* Sets additional time subtracted from the overlap calculated by mixrampdb.
* A value of NaN disables MixRamp overlapping and falls back to crossfading.
*
* @param connection the connection to MPD
* @param seconds seconds subtracted from the overlap calculated by mixrampdb
* @return true on success, false on error
*
* @since libmpdclient 2.2
*/
bool
mpd_send_mixrampdelay(struct mpd_connection *connection, float seconds);
/**
* Shortcut for mpd_send_mixrampdelay() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param seconds seconds subtracted from the overlap calculated by mixrampdb
* @return true on success, false on error
*
* @since libmpdclient 2.2
*/
bool
mpd_run_mixrampdelay(struct mpd_connection *connection, float seconds);
/**
* Clears the current error message in MPD's status (this is also accomplished
* by any command that starts playback).
*
* @param connection the connection to MPD
* @return true on success, false on error
*
* @since libmpdclient 2.4
*/
bool
mpd_send_clearerror(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_clearerror() and mpd_response_finish().
*
* @param connection the connection to MPD
* @return true on success, false on error
*
* @since libmpdclient 2.4
*/
bool
mpd_run_clearerror(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif
|