|
a/upmpd/mpdcli.cxx |
|
b/upmpd/mpdcli.cxx |
|
... |
|
... |
401 |
return -1;
|
401 |
return -1;
|
402 |
LOGDEB("MPDCli::curpos: pos: " << m_stat.songpos << " id "
|
402 |
LOGDEB("MPDCli::curpos: pos: " << m_stat.songpos << " id "
|
403 |
<< m_stat.songid << endl);
|
403 |
<< m_stat.songid << endl);
|
404 |
return m_stat.songpos;
|
404 |
return m_stat.songpos;
|
405 |
}
|
405 |
}
|
|
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
#ifdef MPDCLI_TEST
|
|
|
411 |
|
|
|
412 |
#include <stdio.h>
|
|
|
413 |
#include <stdlib.h>
|
|
|
414 |
#include <unistd.h>
|
|
|
415 |
#include <errno.h>
|
|
|
416 |
#include <string.h>
|
|
|
417 |
|
|
|
418 |
#include <string>
|
|
|
419 |
#include <iostream>
|
|
|
420 |
using namespace std;
|
|
|
421 |
|
|
|
422 |
#include "mpdcli.hxx"
|
|
|
423 |
|
|
|
424 |
static char *thisprog;
|
|
|
425 |
|
|
|
426 |
static char usage [] =
|
|
|
427 |
" \n\n"
|
|
|
428 |
;
|
|
|
429 |
static void
|
|
|
430 |
Usage(void)
|
|
|
431 |
{
|
|
|
432 |
fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
|
|
|
433 |
exit(1);
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
static int op_flags;
|
|
|
437 |
#define OPT_MOINS 0x1
|
|
|
438 |
#define OPT_s 0x2
|
|
|
439 |
#define OPT_b 0x4
|
|
|
440 |
|
|
|
441 |
int main(int argc, char **argv)
|
|
|
442 |
{
|
|
|
443 |
int count = 10;
|
|
|
444 |
|
|
|
445 |
thisprog = argv[0];
|
|
|
446 |
argc--; argv++;
|
|
|
447 |
|
|
|
448 |
while (argc > 0 && **argv == '-') {
|
|
|
449 |
(*argv)++;
|
|
|
450 |
if (!(**argv))
|
|
|
451 |
/* Cas du "adb - core" */
|
|
|
452 |
Usage();
|
|
|
453 |
while (**argv)
|
|
|
454 |
switch (*(*argv)++) {
|
|
|
455 |
case 's': op_flags |= OPT_s; break;
|
|
|
456 |
case 'b': op_flags |= OPT_b; if (argc < 2) Usage();
|
|
|
457 |
if ((sscanf(*(++argv), "%d", &count)) != 1)
|
|
|
458 |
Usage();
|
|
|
459 |
argc--;
|
|
|
460 |
goto b1;
|
|
|
461 |
default: Usage(); break;
|
|
|
462 |
}
|
|
|
463 |
b1: argc--; argv++;
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
if (argc != 0)
|
|
|
467 |
Usage();
|
|
|
468 |
|
|
|
469 |
MPDCli cli("localhost");
|
|
|
470 |
if (!cli.ok()) {
|
|
|
471 |
cerr << "Cli connection failed" << endl;
|
|
|
472 |
return 1;
|
|
|
473 |
}
|
|
|
474 |
const MpdStatus& status = cli.getStatus();
|
|
|
475 |
|
|
|
476 |
if (status.state != MpdStatus::MPDS_PLAY) {
|
|
|
477 |
cerr << "Not playing" << endl;
|
|
|
478 |
return 1;
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
unsigned int seektarget = (status.songlenms - 4500)/1000;
|
|
|
482 |
cerr << "songpos " << status.songpos << " songid " << status.songid <<
|
|
|
483 |
" seeking to " << seektarget << " seconds" << endl;
|
|
|
484 |
|
|
|
485 |
if (!cli.seek(seektarget)) {
|
|
|
486 |
cerr << "Seek failed" << endl;
|
|
|
487 |
return 1;
|
|
|
488 |
}
|
|
|
489 |
return 0;
|
|
|
490 |
}
|
|
|
491 |
|
|
|
492 |
|
|
|
493 |
#endif
|
|
|
494 |
|