Beispiel #1
0
t_size playlist_manager::create_playlist_autoname(t_size p_index) {	
	static const char new_playlist_text[] = "New Playlist";
	if (find_playlist(new_playlist_text,pfc_infinite) == pfc_infinite) return create_playlist(new_playlist_text,pfc_infinite,p_index);
	for(t_size walk = 2; ; walk++) {
		pfc::string_fixed_t<64> namebuffer;
		namebuffer << new_playlist_text << " (" << walk << ")";
		if (find_playlist(namebuffer,pfc_infinite) == pfc_infinite) return create_playlist(namebuffer,pfc_infinite,p_index);
	}
}
/*
 * This function removes a playlist
 */
static GError *
remove_playlist (void)
{
	MafwPlaylistManager *manager;
	MafwPlaylist *playlist;
	GError *error = NULL;
	GPtrArray *list = NULL;
	gint i;

	manager = mafw_playlist_manager_get ();

	playlist = find_playlist (playlist_name, &error);

	if (error != NULL)  {
		return error;
	}

	if (playlist == NULL) {
		return g_error_new (MAFW_ERROR, 0, "Playlist not found");
	}

	mafw_playlist_manager_destroy_playlist (manager,
						playlist,
						&error);

	return error;
}
/*
 * This function assigned a playlist to the renderer.
 * Receives the playlist name to assign as parameter.
 */
static gboolean
do_assign_playlist_request (gpointer user_data)
{
	GError *error = NULL;
	MafwPlaylist *playlist;
	gchar *playlist_name = (gchar *) user_data;

	g_print ("[INFO] Assigning playlist %s to "  WANTED_RENDERER ".\n",
		 playlist_name);

	playlist = find_playlist (playlist_name, &error);

	if (error != NULL)  {
		g_error ("Failed to find playlist\n");
	}

	if (playlist == NULL) {
		g_error ("Playlist not found");
	}

	mafw_renderer_assign_playlist (app_renderer, playlist, &error);

	if (error != NULL) {
		g_error ("Failed to assign playlist: %s\n",
			 error->message);
	}

	return FALSE;
}
Beispiel #4
0
unsigned playlist_switcher::find_or_create_playlist(const char * name)
{
	unsigned idx = find_playlist(name);
	if (idx==(unsigned)(-1))
	{
		metadb_handle_list dummy;
		idx = create_playlist_fixname(string8(name),dummy);
	}
	return idx;
}
static bool_t search_init (void)
{
    find_playlist ();

    search_terms = index_new ();
    items = index_new ();
    selection = g_array_new (FALSE, FALSE, 1);

    update_database ();

    hook_associate ("playlist add complete", add_complete_cb, NULL);
    hook_associate ("playlist scan complete", scan_complete_cb, NULL);
    hook_associate ("playlist update", playlist_update_cb, NULL);

    return TRUE;
}
/*
 * This function removes an item from a playlist
 */
static GError *
remove_item_from_playlist (void)
{
	MafwPlaylist *playlist;
	GError *error = NULL;
	guint size;
	gint i;

	playlist = find_playlist (playlist_name, &error);

	if (error != NULL)  {
		return error;
	}

	if (playlist == NULL) {
		return g_error_new (MAFW_ERROR, 0, "Playlist not found");
	}

	g_print ("  Searching for %s in playlist %s\n",
		 object_id, playlist_name);
	size = mafw_playlist_get_size (playlist, &error);

	if (error != NULL) {
		return error;
	}

	for (i = 0; i < size; i++) {
		gchar *id = mafw_playlist_get_item (playlist, i, &error);
		if (error != NULL) {
			g_warning ("Error getting item %d "
				   "from playlist: %s\n",
				   i, error->message);
			g_error_free (error);
			error = NULL;
		} else if (strcmp (id, object_id) == 0) {
			mafw_playlist_remove_item (playlist, i, &error);
			g_print ("  Element found at position %d\n", i);
			break;
		}
	}

	if (i == size) {
		g_print ("  Element not found\n");
	} else {
		g_print ("Playlist %s removed\n", playlist_name);
	}
}
/*
 * This function shows the object identifiers contained in a playlist
 */
static GError *
show_playlist (void)
{
	MafwPlaylist *playlist;
	GError *error = NULL;
	gint i;
	guint size;

	playlist = find_playlist (playlist_name, &error);

	if (error != NULL)  {
		return error;
	}

	if (playlist == NULL) {
		return g_error_new (MAFW_ERROR, 0, "Playlist not found");
	}

	g_print ("Showing contents for playlist %s...:\n", playlist_name);
	size = mafw_playlist_get_size (playlist, &error);

	if (error != NULL) {
		return error;
	}

	if (size > 0) {
		for (i = 0; i < size; i++) {
			gchar *id =
				mafw_playlist_get_item (playlist, i, &error);
			if (error != NULL) {
				g_warning ("Error getting item %d "
					   "from playlist: %s\n",
					   i, error->message);
				g_error_free (error);
				error = NULL;
			}

			g_print ("  %d %s\n", i, id);
		}
	} else {
		g_print ("Playlist is empty\n");
	}

	return error;
}
/*
 * This function adds an object identifier to a playlist
 */
static GError *
add_item_to_playlist (void)
{
	MafwPlaylist *playlist;
	GError *error = NULL;

	playlist = find_playlist (playlist_name, &error);

	if (error != NULL)  {
		return error;
	}

	if (playlist == NULL) {
		return g_error_new (MAFW_ERROR, 0, "Playlist not found");
	}

	mafw_playlist_insert_item (playlist, 0, object_id, &error);
	return error;
}
Beispiel #9
0
t_size playlist_manager::find_or_create_playlist(const char * p_name,t_size p_name_length)
{
	t_size index = find_playlist(p_name,p_name_length);
	if (index != pfc_infinite) return index;
	return create_playlist(p_name,p_name_length,pfc_infinite);
}