Exemple #1
0
/* ----------------------------------------------------------------------- */
static char* create_bookmark()
{
    int resume_index = 0;
    char *file;

    if (!bookmark_is_bookmarkable_state())
        return NULL; /* something didn't happen correctly, do nothing */

    /* grab the currently playing track */
    struct mp3entry *id3 = audio_current_track();
    if(!id3)
        return NULL;

    /* Get some basic resume information */
    /* queue_resume and queue_resume_index are not used and can be ignored.*/
    playlist_get_resume_info(&resume_index);

    /* Get the currently playing file minus the path */
    /* This is used when displaying the available bookmarks */
    file = strrchr(id3->path,'/');
    if(NULL == file)
        return NULL;

    /* create the bookmark */
    snprintf(global_bookmark, sizeof(global_bookmark),
             /* new optional bookmark token descriptors should be inserted
                just before the "%s;%s" in this line... */
#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL)
             ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s",
#else
             ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s",
#endif
             /* ... their flags should go here ... */
#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL)
             BM_PITCH | BM_SPEED,
#else
             0,
#endif
             resume_index,
             id3->offset,
             playlist_get_seed(NULL),
             id3->elapsed,
             global_settings.repeat_mode,
             global_settings.playlist_shuffle,
             /* ...and their values should go here */
#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL)
             (long)sound_get_pitch(),
             (long)dsp_get_timestretch(),
#endif
             /* more mandatory tokens */
             playlist_get_name(NULL, global_temp_buffer,
                sizeof(global_temp_buffer)),
             file+1);

    /* checking to see if the bookmark is valid */
    if (parse_bookmark(global_bookmark, false))
        return global_bookmark;
    else
        return NULL;
}
Exemple #2
0
/* ------------------------------------------------------------------------*/
static bool write_bookmark(bool create_bookmark_file, const char *bookmark)
{
    bool ret=true;

    if (!bookmark)
    {
       ret = false; /* something didn't happen correctly, do nothing */
    }
    else
    {
        if (global_settings.usemrb)
            ret = add_bookmark(RECENT_BOOKMARK_FILE, bookmark, true);


        /* writing the bookmark */
        if (create_bookmark_file)
        {
            char* name = playlist_get_name(NULL, global_temp_buffer,
                                       sizeof(global_temp_buffer));
            if (generate_bookmark_file_name(name))
            {
                ret = ret & add_bookmark(global_bookmark_file_name, bookmark, false);
            }
            else
            {
                ret = false; /* generating bookmark file failed */
            }
        }
    }

    splash(HZ, ret ? ID2P(LANG_BOOKMARK_CREATE_SUCCESS)
           : ID2P(LANG_BOOKMARK_CREATE_FAILURE));

    return ret;
}
t_size playlist_manager::find_or_create_playlist_unlocked(const char * p_name, t_size p_name_length) {
	t_size n, m = get_playlist_count();
	pfc::string_formatter temp;
	for(n=0;n<m;n++) {
		if (!playlist_lock_is_present(n) && playlist_get_name(n,temp)) {
			if (stricmp_utf8_ex(temp,~0,p_name,p_name_length) == 0) return n;
		}
	}
	return create_playlist(p_name,p_name_length,pfc_infinite);
}
t_size playlist_manager::find_playlist(const char * p_name,t_size p_name_length)
{
	t_size n, m = get_playlist_count();
	pfc::string_formatter temp;
	for(n=0;n<m;n++) {
		if (!playlist_get_name(n,temp)) break;
		if (stricmp_utf8_ex(temp,temp.length(),p_name,p_name_length) == 0) return n;
	}
	return pfc_infinite;
}
Exemple #5
0
/* ----------------------------------------------------------------------- */
bool bookmark_exists(void)
{
    bool exist=false;

    char* name = playlist_get_name(NULL, global_temp_buffer,
                                   sizeof(global_temp_buffer));
    if (generate_bookmark_file_name(name))
    {
        exist = file_exists(global_bookmark_file_name);
    }
    return exist;
}
Exemple #6
0
void command_qaddpl(const struct command * const command)
{	
	while(queue_get_len() != 0) queue_del_track(0);
	if(playlist_for_each(command->playlist, &queue_add_track))
	{
		sock_send_str(command->sockfd, "Added playlist \"");
		char buf[API_MESSAGE_LEN];
		playlist_get_name(buf, API_MESSAGE_LEN, command->playlist);
		sock_send_str(command->sockfd, buf);
		sock_send_str(command->sockfd, "\" to queue.\n");
	}
	else
	{
		sock_send_str(command->sockfd, "No such playlist.\n");
	}
}
Exemple #7
0
void command_pl(const struct command * const command)
{
	unsigned i = 0;
	for(i = 0; i<playlist_len(); ++i)
	{
		char playlist_name[API_MESSAGE_LEN];
		playlist_get_name(playlist_name, API_MESSAGE_LEN, i);
		if(playlist_name == NULL)
		{
			break;
		}
		char name_str[API_MESSAGE_LEN];
		snprintf(name_str, API_MESSAGE_LEN, "%d | %s\n", i, playlist_name);
		sock_send_str(command->sockfd, name_str);
	}
}
Exemple #8
0
void command_plrm(const struct command * const command)
{
	if(playlist_del_track(command->playlist, command->track))
	{
		sock_send_str(command->sockfd, "Removed track ");
		char buf[API_MESSAGE_LEN];
		track_to_str(buf, API_MESSAGE_LEN, queue_get(command->track));
		sock_send_str(command->sockfd, buf);
		sock_send_str(command->sockfd, " from playlist ");
		playlist_get_name(buf, API_MESSAGE_LEN, command->playlist);
		sock_send_str(command->sockfd, buf);
		sock_send_str(command->sockfd, ".\n");
	}
	else
	{
		sock_send_str(command->sockfd, "Couldn't remove track.\n");
	}

}
Exemple #9
0
void command_pladd(sp_session *session, const struct command * const command)
{
	sp_track *t = queue_get(command->track);
	if(t != NULL && playlist_add_track(command->playlist, t, session))
	{
		sock_send_str(command->sockfd, "Added track ");
		char buf[API_MESSAGE_LEN];
		track_to_str(buf, API_MESSAGE_LEN, queue_get(command->track));
		sock_send_str(command->sockfd, buf);
		sock_send_str(command->sockfd, " to playlist ");
		playlist_get_name(buf, API_MESSAGE_LEN, command->playlist);
		sock_send_str(command->sockfd, buf);
		sock_send_str(command->sockfd, ".\n");
	}
	else
	{
		sock_send_str(command->sockfd, "Couldn't add track.\n");
	}

}
Exemple #10
0
/* ----------------------------------------------------------------------- */
int bookmark_load_menu(void)
{
    char* bookmark;
    int ret = BOOKMARK_FAIL;

    push_current_activity(ACTIVITY_BOOKMARKSLIST);

    char* name = playlist_get_name(NULL, global_temp_buffer,
                                       sizeof(global_temp_buffer));
    if (generate_bookmark_file_name(name))
    {
        ret = select_bookmark(global_bookmark_file_name, false, &bookmark);
        if (bookmark != NULL)
        {
            ret = play_bookmark(bookmark) ? BOOKMARK_SUCCESS : BOOKMARK_FAIL;
        }
    }

    pop_current_activity();
    return ret;
}
bool playlist_manager::activeplaylist_get_name(pfc::string_base & p_out)
{
	t_size playlist = get_active_playlist();
	if (playlist == pfc_infinite) return false;
	else return playlist_get_name(playlist,p_out);
}