diff -Naur xmms-1.2.10/libxmms/xmmsctrl.c xmms-1.2.10.sid-songpos/libxmms/xmmsctrl.c --- xmms-1.2.10/libxmms/xmmsctrl.c 2004-02-23 20:31:42.000000000 +0000 +++ xmms-1.2.10.sid-songpos/libxmms/xmmsctrl.c 2004-02-25 07:05:29.000000000 +0000 @@ -422,6 +422,11 @@ remote_send_guint32(session, CMD_JUMP_TO_TIME, pos); } +void xmms_remote_seek(gint session, gint off) +{ + remote_send_guint32(session, CMD_SEEK, off); +} + void xmms_remote_get_volume(gint session, gint * vl, gint * vr) { ServerPktHeader pkt_hdr; diff -Naur xmms-1.2.10/libxmms/xmmsctrl.h xmms-1.2.10.sid-songpos/libxmms/xmmsctrl.h --- xmms-1.2.10/libxmms/xmmsctrl.h 2003-06-11 18:44:17.000000000 +0000 +++ xmms-1.2.10.sid-songpos/libxmms/xmmsctrl.h 2004-02-25 07:05:29.000000000 +0000 @@ -42,6 +42,7 @@ void xmms_remote_playlist_clear(gint session); gint xmms_remote_get_output_time(gint session); void xmms_remote_jump_to_time(gint session, gint pos); +void xmms_remote_seek(gint session, gint off); void xmms_remote_get_volume(gint session, gint * vl, gint * vr); gint xmms_remote_get_main_volume(gint session); gint xmms_remote_get_balance(gint session); diff -Naur xmms-1.2.10/xmms/controlsocket.c xmms-1.2.10.sid-songpos/xmms/controlsocket.c --- xmms-1.2.10/xmms/controlsocket.c 2004-02-23 20:31:43.000000000 +0000 +++ xmms-1.2.10.sid-songpos/xmms/controlsocket.c 2004-02-25 07:05:29.000000000 +0000 @@ -502,6 +502,10 @@ num < playlist_get_current_length()) input_seek(num / 1000); break; + case CMD_SEEK: + num = *((guint32 *) data); + song_seek(num); + break; case CMD_SET_VOLUME: v[0] = ((guint32 *) data)[0]; v[1] = ((guint32 *) data)[1]; diff -Naur xmms-1.2.10/xmms/controlsocket.h xmms-1.2.10.sid-songpos/xmms/controlsocket.h --- xmms-1.2.10/xmms/controlsocket.h 2003-06-11 18:44:17.000000000 +0000 +++ xmms-1.2.10.sid-songpos/xmms/controlsocket.h 2004-02-25 07:05:29.000000000 +0000 @@ -33,7 +33,7 @@ CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP, CMD_IS_PLAYING, CMD_IS_PAUSED, CMD_GET_PLAYLIST_POS, CMD_SET_PLAYLIST_POS, CMD_GET_PLAYLIST_LENGTH, CMD_PLAYLIST_CLEAR, - CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_GET_VOLUME, + CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_SEEK, CMD_GET_VOLUME, CMD_SET_VOLUME, CMD_GET_SKIN, CMD_SET_SKIN, CMD_GET_PLAYLIST_FILE, CMD_GET_PLAYLIST_TITLE, CMD_GET_PLAYLIST_TIME, CMD_GET_INFO, CMD_GET_EQ_DATA, CMD_SET_EQ_DATA, CMD_PL_WIN_TOGGLE, diff -Naur xmms-1.2.10/xmms/input.c xmms-1.2.10.sid-songpos/xmms/input.c --- xmms-1.2.10/xmms/input.c 2003-08-08 17:10:44.000000000 +0000 +++ xmms-1.2.10.sid-songpos/xmms/input.c 2004-02-25 07:05:29.000000000 +0000 @@ -306,6 +306,7 @@ } } ip_data->playing = FALSE; + set_song_position(0, 0, 0); } void input_pause(void) diff -Naur xmms-1.2.10/xmms/main.c xmms-1.2.10.sid-songpos/xmms/main.c --- xmms-1.2.10/xmms/main.c 2004-02-23 20:31:43.000000000 +0000 +++ xmms-1.2.10.sid-songpos/xmms/main.c 2004-02-25 07:05:30.000000000 +0000 @@ -678,6 +678,55 @@ g_free(filename); } +/*\ +|*| Separate song position stuff, for songs without a time length, +|*| but that want to be able to seek anyway. +|*| +|*| Have the input plugin's get_time() function call +|*| set_song_position(int pos, int first, int last) +|*| to set the slider. If the slider is dragged, +|*| the plugin's seek() is called with the position. +|*| (If last <= first the feature is turned off) +\*/ + +static int song_pos_cur, song_pos_first, song_pos_num = 0; + +void set_song_position(int pos, int first, int last) +{ + last -= first; + song_pos_cur = pos; + song_pos_first = first; + song_pos_num = last; + if (last <= 0) return; + pos -= first; + if (pos > last) pos = last; + if (cfg.player_shaded) + show_widget(mainwin_sposition); + show_widget(mainwin_position); + hslider_set_position(mainwin_position, (pos * 219) / last); + hslider_set_position(mainwin_sposition, ((pos * 12) / last) + 1); +} + +void song_seek(gint off) +{ + if (!get_input_playing()) return; + if (song_pos_num > 0) { + gint newpos = 0; + if (off < 0) newpos = song_pos_cur - 1; + else if (off > 0) newpos = song_pos_cur + 1; + if (newpos < song_pos_first) newpos = song_pos_first; + if (newpos > song_pos_first + song_pos_num) + newpos = song_pos_first + song_pos_num; + input_seek(newpos); + } else { + gint newpos = (input_get_time() / 1000) + (off / 1000); + gint pcl = playlist_get_current_length() / 1000; + if (newpos >= pcl) newpos = pcl - 1; + if (newpos < 0) newpos = 0; + input_seek(newpos); + } +} + gchar *xmms_get_gentitle_format(void) { return cfg.gentitle_format; @@ -757,7 +806,9 @@ show_widget(mainwin_stime_min); show_widget(mainwin_stime_sec); - if (get_input_playing() && playlist_get_current_length() != -1) + if (get_input_playing() && + ((playlist_get_current_length() != -1) || + (song_pos_num > 0))) show_widget(mainwin_sposition); mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; @@ -1079,7 +1130,7 @@ show_widget(mainwin_sec_num); if (!get_input_paused()) playstatus_set_status(mainwin_playstatus, STATUS_PLAY); - if (playlist_get_current_length() != -1) + if ((playlist_get_current_length() != -1) || (song_pos_num > 0)) { if (cfg.player_shaded) show_widget(mainwin_sposition); @@ -1398,13 +1449,19 @@ break; case GDK_Left: case GDK_KP_Left: +/* if(playlist_get_current_length() != -1) input_seek(CLAMP(input_get_time() - 5000, 0, playlist_get_current_length()) / 1000); +*/ + song_seek(-5000); break; case GDK_Right: case GDK_KP_Right: +/* if(playlist_get_current_length() != -1) input_seek(CLAMP(input_get_time() + 5000, 0, playlist_get_current_length()) / 1000); +*/ + song_seek(+5000); break; default: break; @@ -2084,6 +2141,16 @@ pos--; + if (song_pos_num > 0) { + time = ((song_pos_num * pos + 6) / 12) + song_pos_first; + tmp = g_strdup_printf("%d", time); + textbox_set_text(mainwin_stime_min, tmp); + g_free(tmp); + tmp = g_strdup_printf("%d", song_pos_first + song_pos_num); + textbox_set_text(mainwin_stime_sec, tmp); + g_free(tmp); + return; + } time = ((playlist_get_current_length() / 1000) * pos) / 12; if (cfg.timer_mode == TIMER_REMAINING) { @@ -2105,6 +2172,10 @@ void mainwin_spos_release_cb(gint pos) { + if (song_pos_num > 0) { + input_seek(((song_pos_num * (pos - 1) + 6) / 12) + song_pos_first); + return; + } input_seek(((playlist_get_current_length() / 1000) * (pos - 1)) / 12); } @@ -2113,6 +2184,14 @@ gint length, time; gchar *buf; + if (song_pos_num > 0) { + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; + buf = g_strdup_printf("JUMP TO: %d/%d", time, + song_pos_num + song_pos_first); + mainwin_lock_info_text(buf); + g_free(buf); + return; + } length = playlist_get_current_length() / 1000; time = (length * pos) / 219; buf = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), time / 60, time % 60, length / 60, length % 60, (length != 0) ? (time * 100) / length : 0); @@ -2124,6 +2203,12 @@ { int length, time; + if (song_pos_num > 0) { + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; + input_seek(time); + mainwin_release_info_text(); + return; + } length = playlist_get_current_length() / 1000; time = (length * pos) / 219; input_seek(time); @@ -2530,12 +2615,10 @@ case MAINWIN_GENERAL_STOPFADE: break; case MAINWIN_GENERAL_BACK5SEC: - if (get_input_playing() && playlist_get_current_length() != -1) - input_seek((((input_get_time() / 1000) - 5 >= 0) ? (input_get_time() / 1000) - 5 : 0)); + song_seek(-5000); break; case MAINWIN_GENERAL_FWD5SEC: - if (get_input_playing() && playlist_get_current_length() != -1) - input_seek(((((input_get_time() / 1000) + 5) < (playlist_get_current_length() / 1000)) ? ((input_get_time() / 1000) + 5) : ((playlist_get_current_length() / 1000) - 1))); + song_seek(+5000); break; case MAINWIN_GENERAL_START: playlist_set_position(0); @@ -3147,7 +3230,7 @@ hslider_set_position(mainwin_sposition, ((time * 12) / length) + 1); } } - else + else if (song_pos_num <= 0) { hslider_set_position(mainwin_position, 0); hslider_set_position(mainwin_sposition, 1); diff -Naur xmms-1.2.10/xmms/main.h xmms-1.2.10.sid-songpos/xmms/main.h --- xmms-1.2.10/xmms/main.h 2003-12-07 02:06:43.000000000 +0000 +++ xmms-1.2.10.sid-songpos/xmms/main.h 2004-02-25 07:05:30.000000000 +0000 @@ -85,6 +85,7 @@ void mainwin_play_pushed(void); void mainwin_stop_pushed(void); void mainwin_eject_pushed(void); +void song_seek(gint off); void mainwin_set_back_pixmap(void); diff -Naur xmms-1.2.10/xmms/plugin.h xmms-1.2.10.sid-songpos/xmms/plugin.h --- xmms-1.2.10/xmms/plugin.h 2001-07-05 22:35:01.000000000 +0000 +++ xmms-1.2.10.sid-songpos/xmms/plugin.h 2004-02-25 07:05:30.000000000 +0000 @@ -154,4 +154,6 @@ void (*render_freq)(gint16 freq_data[2][256]); /* Render the freq data, don't do anything time consuming in here */ } VisPlugin; +void set_song_position(int pos, int first, int last); + #endif