6 #include <xmms/xmmsctrl.h>
14 int tstart, tstop, fstart, fstop;
20 struct pl *pl = NULL, *p, **l = &pl;
22 char buf[1024], b2[1024];
23 FILE *f = fopen(name, "r");
25 fprintf(stderr, "Unable to open %s: %m\n", name);
28 while (fgets(buf, sizeof(buf), f)) {
29 p = malloc(sizeof(struct pl));
31 if (sscanf(buf, "%d%d %[^\n]", &p->tstart, &p->tstop, b2) != 3) {
32 fprintf(stderr, "Syntax error in %s, line %d\n", name, cnt);
35 p->name = g_strdup(b2);
36 p->fstart = p->tstart + 1000;
37 p->fstop = p->tstop - 1000;
38 printf("%02d: <%s> %d %d %d %d\n", p->id, p->name, p->tstart, p->fstart, p->fstop, p->tstop);
45 fprintf(stderr, "The track list is empty!\n");
52 feed_pl(struct pl *pl)
55 xmms_remote_stop(session);
56 xmms_remote_set_main_volume(session, 0);
57 xmms_remote_playlist_clear(session);
60 l = g_list_append(l, pl->name);
63 xmms_remote_playlist_add(session, l);
69 int t0 = xmms_remote_get_output_time(session);
71 int t = xmms_remote_get_output_time(session) - t0;
72 printf("%d %d\n",t,t0 );
73 if (t >= l || t < 0) {
74 xmms_remote_set_main_volume(session, 100);
77 xmms_remote_set_main_volume(session, t*100/l);
88 xmms_remote_set_main_volume(session, n);
92 int main(int argc, char **argv)
94 struct pl *pl, *this = NULL;
95 int state = -1, st, t;
98 fprintf(stderr, "Usage: jukebox <file-with-track-list>\n");
101 pl = load_pl(argv[1]);
103 if (!xmms_remote_is_running(session)) {
104 fprintf(stderr, "No XMMS session found.\n");
109 if (!xmms_remote_is_running(session)) {
110 fprintf(stderr, "XMMS exited.\n");
113 if (!xmms_remote_is_playing(session)) {
120 st = xmms_remote_get_playlist_pos(session);
123 printf("### Start %d\n", state);
124 for (this=pl; this && this->id != state; this = this->next)
127 fprintf(stderr, "Internal error: unknown song ID\n");
131 xmms_remote_jump_to_time(session, this->tstart);
133 t = xmms_remote_get_output_time(session);
134 //printf(" %d %d\n", st, t);
135 if (t < this->tstart)
137 else if (t < this->fstart)
138 vol(100 * ((t - this->tstart) / (float)(this->fstart - this->tstart)));
139 else if (t < this->fstop)
141 else if (t < this->tstop)
142 vol(100 * (1-((t - this->fstop) / (float)(this->tstop - this->fstop))));
146 xmms_remote_playlist_next(session);
148 xmms_remote_stop(session);