예제 #1
0
static int timeout_func(gpointer data)
{
	int pos;
	gboolean playing;
	static char *previous_file = NULL;
	static gboolean cmd_after_already_run = FALSE;
	char *current_file;

	GDK_THREADS_ENTER();

	playing = xmms_remote_is_playing(sc_gp.xmms_session);
	pos = xmms_remote_get_playlist_pos(sc_gp.xmms_session);
	current_file = xmms_remote_get_playlist_file(sc_gp.xmms_session, pos);
	
	if ((pos != previous_song ||
	     (!previous_file && current_file) ||
	     (previous_file && !current_file) ||
	     (previous_file && current_file &&
	      strcmp(previous_file, current_file))) &&
	    xmms_remote_get_output_time(sc_gp.xmms_session) > 0)
	{
		do_command(cmd_line, current_file, pos);
		g_free(previous_file);
		previous_file = g_strdup(current_file);
		previous_song = pos;
		cmd_after_already_run = FALSE;
	}
	if (!cmd_after_already_run &&
	    ((xmms_remote_get_playlist_time(sc_gp.xmms_session,pos) -
	      xmms_remote_get_output_time(sc_gp.xmms_session)) < 100))
	{
		do_command(cmd_line_after, current_file, pos);
		cmd_after_already_run = TRUE;
	}

	if (playing)
	{
		int playlist_length = xmms_remote_get_playlist_length(sc_gp.xmms_session);
		if (pos + 1 == playlist_length)
			possible_pl_end = TRUE;
		else
			possible_pl_end = FALSE;
	}
	else if (possible_pl_end)
	{
		if (pos == 0)
			do_command(cmd_line_end, current_file, pos);
		possible_pl_end = FALSE;
		g_free(previous_file);
		previous_file = NULL;
	}

	g_free(current_file);
	current_file = NULL;

	GDK_THREADS_LEAVE();

	return TRUE;
}
예제 #2
0
static void start_music0 (gchar *filename)
{
    gchar *playlist[1];
    gint i;

    playlist[0] = filename;

    old_length = xmms_remote_get_playlist_length (0);
    old_playlist = (gchar **) g_malloc (old_length * sizeof (gchar *));
    for (i = 0; i < old_length; i++)
	old_playlist[i] = xmms_remote_get_playlist_file (0, i);

#ifdef XMMS_PLAYLIST_BUG
    xmms_remote_playlist_clear (0);
    xmms_remote_playlist (0, playlist, 1, TRUE);
    xmms_remote_play (0);
#else
    xmms_remote_playlist (0, playlist, 1, FALSE);
#endif

    old_repeat = xmms_remote_is_repeat (0);
    if (!old_repeat)
	xmms_remote_toggle_repeat (0);
}