Example #1
0
void playlist_delete_filenames(GList *filenames)
{
    GList *node, *fnode;
    gboolean set_info_text = FALSE, restart_playing = FALSE;

    PL_LOCK();
    for (fnode = filenames; fnode; fnode = g_list_next(fnode))
    {
        node = playlist;
        while (node)
        {
            GList *next = g_list_next(node);
            PlaylistEntry *entry = node->data;
            if (!strcmp(entry->filename, fnode->data))
                playlist_delete_node(node, &set_info_text,
                                     &restart_playing);
            node = next;
        }
    }

    PL_UNLOCK();

    playlistwin_update_list();
    if (restart_playing)
    {
        if (playlist_position)
            playlist_play();
        else
            mainwin_clear_song_info();
    }
    else if (set_info_text)
        mainwin_set_info_text();
}
Example #2
0
void playlist_delete(gboolean crop)
{
    gboolean restart_playing = FALSE, set_info_text = FALSE;
    GList *node, *next;
    PlaylistEntry *entry;

    PL_LOCK();

    node = playlist;

    while (node)
    {
        entry = node->data;
        next = g_list_next(node);
        if ((entry->selected && !crop) || (!entry->selected && crop))
            playlist_delete_node(node, &set_info_text, &restart_playing);
        node = next;
    }
    PL_UNLOCK();

    playlistwin_update_list();
    if (restart_playing)
    {
        if (playlist_position)
            playlist_play();
        else
            mainwin_clear_song_info();
    }
    else if (set_info_text)
        mainwin_set_info_text();
}
enum playlist_result
playlist_play_id(struct playlist *playlist, struct player_control *pc,
		 int id)
{
	int song;

	if (id == -1) {
		return playlist_play(playlist, pc, id);
	}

	song = queue_id_to_position(&playlist->queue, id);
	if (song < 0)
		return PLAYLIST_RESULT_NO_SUCH_SONG;

	return playlist_play(playlist, pc, song);
}
Example #4
0
void playlist_delete_index(glong index)
{
    gboolean restart_playing = FALSE, set_info_text = FALSE;
    GList *node;

    PL_LOCK();
    if (!playlist)
    {
        PL_UNLOCK();
        return;
    }

    node = g_list_nth(playlist, index);
    if(!node)
    {
        PL_UNLOCK();
        return;
    }

    playlist_delete_node(node, &set_info_text, &restart_playing);

    PL_UNLOCK();

    playlistwin_update_list();
    if (restart_playing)
    {
        if (playlist_position)
            playlist_play();
        else
            mainwin_clear_song_info();
    }
    else if (set_info_text)
        mainwin_set_info_text();
}
Example #5
0
File: fb.c Project: gettler/mvpmc
void
fb_shuffle(int shuffle)
{
	char **item, *tmp;
	int i, j, k, n;

	if (shuffle)
		mvpw_set_menu_title(playlist_widget, "Shuffle Play");
	else
		mvpw_set_menu_title(playlist_widget, "Play All");
	
	item = alloca(sizeof(char*) * MAX_PLAYLIST_ENTRIES);

	// Recurse from the current directory and find all
	// audio files
	n = 0;
	recurse_find_audio(cwd, item, &n);
	
	if (n == 0) {
		gui_error("No audio files exist in this directory or its subdirectories");
		return;
	}

	if (shuffle && (n > 1)) {
		for (i=0; i < MAX_PLAYLIST_ENTRIES; i++) {
			j = rand() % n;
			k = rand() % n;
			tmp = item[k];
			item[k] = item[j];
			item[j] = tmp;
		}
	}

	printf("created playlist of %d songs\n", n);

	switch_hw_state(MVPMC_STATE_FILEBROWSER);
	video_functions = &file_functions;

	playlist_clear();

	mvpw_show(playlist_widget);
	mvpw_focus(playlist_widget);

	playlist_create(item, n);

	// Release the list of items
	for (i = 0; i < n; i++)
		free(item[i]);

	if (shuffle)
		mvpw_set_text_str(fb_name, "Shuffle Play");
	else
		mvpw_set_text_str(fb_name, "Play All");

	mvpw_show(fb_progress);
	mvpw_set_timer(fb_progress, fb_osd_update, 500);
	playlist_play(NULL);
}
Example #6
0
void playlist_eof_reached(void)
{
    GList *plist_pos_list;

    input_stop();

    PL_LOCK();
    plist_pos_list = find_playlist_position_list();

    if (cfg.no_playlist_advance)
    {
        PL_UNLOCK();
        mainwin_clear_song_info();
        if (cfg.repeat)
            playlist_play();
        return;
    }
    if (queued_list)
        play_queued();
    else if (!g_list_next(plist_pos_list))
    {
        if (cfg.shuffle)
        {
            playlist_position = NULL;
            __playlist_generate_shuffle_list();
        }
        else
            playlist_position = playlist->data;
        if (!cfg.repeat)
        {
            PL_UNLOCK();
            mainwin_clear_song_info();
            mainwin_set_info_text();
            return;
        }
    }
    else
        playlist_position = plist_pos_list->next->data;
    PL_UNLOCK();
    playlist_check_pos_current();
    playlist_play();
    mainwin_set_info_text();
    playlistwin_update_list();
}
Example #7
0
void playlist_prev(void)
{
    GList *plist_pos_list;
    gboolean restart_playing = FALSE;

    PL_LOCK();
    if (!playlist)
    {
        PL_UNLOCK();
        return;
    }

    plist_pos_list = find_playlist_position_list();

    if (!cfg.repeat && !g_list_previous(plist_pos_list))
    {
        PL_UNLOCK();
        return;
    }

    if (get_input_playing())
    {
        /* We need to stop before changing playlist_position */
        PL_UNLOCK();
        input_stop();
        PL_LOCK();
        restart_playing = TRUE;
    }

    plist_pos_list = find_playlist_position_list();
    if (g_list_previous(plist_pos_list))
        playlist_position = plist_pos_list->prev->data;
    else if (cfg.repeat)
    {
        GList *node;
        playlist_position = NULL;
        __playlist_generate_shuffle_list();
        if (cfg.shuffle)
            node = g_list_last(shuffle_list);
        else
            node = g_list_last(playlist);
        if (node)
            playlist_position = node->data;
    }
    PL_UNLOCK();
    playlist_check_pos_current();

    if (restart_playing)
        playlist_play();
    else
    {
        mainwin_set_info_text();
        playlistwin_update_list();
    }
}
Example #8
0
void playlist_set_position(int pos)
{
    GList *node;
    gboolean restart_playing = FALSE;

    PL_LOCK();
    if (!playlist)
    {
        PL_UNLOCK();
        return;
    }

    node = g_list_nth(playlist, pos);
    if (!node)
    {
        PL_UNLOCK();
        return;
    }

    if (get_input_playing())
    {
        /* We need to stop before changing playlist_position */
        PL_UNLOCK();
        input_stop();
        PL_LOCK();
        restart_playing = TRUE;
    }

    playlist_position = node->data;
    PL_UNLOCK();
    playlist_check_pos_current();

    if (restart_playing)
        playlist_play();
    else
    {
        mainwin_set_info_text();
        playlistwin_update_list();
    }

    /*
     * Regenerate the shuffle list when the user set a position
     * manually
     */
    playlist_generate_shuffle_list();
}
Example #9
0
void playlist_list_button_press_cb(GtkWidget * widget, GdkEventButton * event, PlayList_List * pl)
{
	if (event->button == 1 && pl->pl_fheight &&
	    inside_widget(event->x, event->y, &pl->pl_widget))
	{
		int nr, y;

		y = event->y - pl->pl_widget.y;
		nr = (y / pl->pl_fheight) + pl->pl_first;
		if (nr >= get_playlist_length())
			nr = get_playlist_length() - 1;
		if (!(event->state & GDK_CONTROL_MASK))
			playlist_select_all(FALSE);
		
		if (event->state & GDK_SHIFT_MASK && pl->pl_prev_selected != -1)
		{
			playlist_select_range(pl->pl_prev_selected, nr, TRUE);
			pl->pl_prev_min = pl->pl_prev_selected;
			pl->pl_prev_max = nr;
			pl->pl_drag_pos = nr - pl->pl_first;
		}
		else
		{
			if (playlist_select_invert(nr))
			{
				if (event->state & GDK_CONTROL_MASK)
				{
					if (pl->pl_prev_min == -1)
					{
						pl->pl_prev_min =
							pl->pl_prev_selected;
						pl->pl_prev_max =
							pl->pl_prev_selected;
					}
					if (nr < pl->pl_prev_min)
						pl->pl_prev_min = nr;
					else if (nr > pl->pl_prev_max)
						pl->pl_prev_max = nr;
				}
				else
					pl->pl_prev_min = -1;
				pl->pl_prev_selected = nr;
				pl->pl_drag_pos = nr - pl->pl_first;
			}
		}
		if (event->type == GDK_2BUTTON_PRESS)
		{
			/*
			 * Ungrab the pointer to prevent us from
			 * hanging on to it during the sometimes slow
			 * playlist_play().
			 */
			gdk_pointer_ungrab(GDK_CURRENT_TIME);
			gdk_flush();
			playlist_set_position(nr);
			if (!get_input_playing())
				playlist_play();
		}
		pl->pl_dragging = TRUE;
		playlistwin_update_list();
	}
}
Example #10
0
File: fb.c Project: gettler/mvpmc
static void
select_callback(mvp_widget_t *widget, char *item, void *key)
{
	char path[1024], *ptr;
	struct stat64 sb;

	sprintf(path, "%s/%s", cwd, item);
	if (stat64(path, &sb)!=0) {
		printf("Could not stat %s error %d\n",item,errno);
		if (strcmp(item,"../")==0 ) {
			// probably lost network put you back in root
			strcpy(cwd,"/");
			strcpy(path,"/");
			stat64(path, &sb);
		}
	}

	if (current_pl && !is_playlist(item)) {
		free(current_pl);
		current_pl = NULL;
	}

	if (current_pl && (playlist == NULL)) {
		free(current_pl);
		current_pl = NULL;
	}

	printf("%s(): path '%s'\n", __FUNCTION__, path);

	if (current && (strcmp(path, current) == 0)) {
		printf("selected current item\n");
		if (is_video(item) || (is_streaming(item) > 100)) {
			mvpw_hide(widget);
			mvpw_hide(fb_progress);
			av_move(0, 0, 0);
			screensaver_disable();
			return;
		}
	}

	if (current_pl && (strcmp(path, current_pl) == 0)) {
		if (is_playlist(item)) {
			mvpw_show(fb_progress);
			mvpw_set_timer(fb_progress, fb_osd_update, 500);
			mvpw_hide(widget);
			printf("Show playlist menu\n");
			mvpw_show(playlist_widget);
			mvpw_focus(playlist_widget);
			return;
		}
	}

	if (S_ISDIR(sb.st_mode)) {
		if (strcmp(item, "../") == 0) {
			strcpy(path, cwd);
			if (path[strlen(path)-1] == '/')
				path[strlen(path)-1] = '\0';
			if ((ptr=strrchr(path, '/')) != NULL)
				*ptr = '\0';
			if (path[0] == '\0')
				sprintf(path, "/");
		} else {
			if ((ptr=strrchr(path, '/')) != NULL)
				*ptr = '\0';
		}
		if (strstr(path,"/uPnP")!=NULL && strstr(cwd,"/uPnP")==NULL ){
			mount_djmount(path);
				
		} else if (strstr(path,"/uPnP")==NULL && strstr(cwd,"/uPnP")!=NULL ) { 
			unmount_djmount();
		}
		strncpy(cwd, path, sizeof(cwd));

		while ((cwd[0] == '/') && (cwd[1] == '/'))
			memmove(cwd, cwd+1, strlen(cwd));

		mvpw_clear_menu(widget);
		mvpw_set_menu_title(widget, cwd);

		busy_start();
		add_dirs(widget);
		add_files(widget);
		busy_end();

		mvpw_expose(widget);
	} else {
		switch_hw_state(MVPMC_STATE_FILEBROWSER);

		if (current)
			free(current);
		current = NULL;
		audio_stop = 1;
		pthread_kill(audio_thread, SIGURG);

		while (audio_playing)
			usleep(1000);

		current = strdup(path);

		if (is_streaming(item) > 100) {
			// Use VLC callbacks for streaming items
			video_functions = &vlc_functions;
			// Allow broadcast messages to be sent so
			// we can tell VLC to start the stream
			vlc_broadcast_enabled = 1;
		} else {
			video_functions = &file_functions;
		}

		add_osd_widget(fb_program_widget, OSD_PROGRAM,
			       osd_settings.program, NULL);

		mvpw_set_text_str(fb_name, item);

		/*
		 * This code sends the currently playing file name to the display.
		 */
		snprintf(display_message, sizeof(display_message),
			 "File:%s\n", item);
		display_send(display_message);

		audio_clear();
		video_clear();
		playlist_clear();

		if (is_video(item)) {
			if (key != NULL) {
				mvpw_hide(widget);
				mvpw_hide(fb_progress);
				av_move(0, 0, 0);
			} else {
				mvpw_show(fb_progress);
			}
			mvpw_set_timer(fb_progress, fb_osd_update, 500);
			video_play(NULL);
			mvpw_show(root);
			mvpw_expose(root);
			mvpw_focus(root);
		} else if (is_audio(item) || is_streaming(item)>=0 ) {
			mvpw_show(fb_progress);
			mvpw_set_timer(fb_progress, fb_osd_update, 500);
			audio_play(NULL);
		} else if (is_image(item)) {
			mvpw_hide(widget);
			printf("Displaying image '%s'\n", path);
			if (mvpw_load_image_jpeg(iw, path) == 0) {
				mvpw_show_image_jpeg(iw);
				av_wss_update_aspect(WSS_ASPECT_UNKNOWN);
			} else {
				mvpw_set_image(iw, path);
			}
			mvpw_show(iw);
			mvpw_focus(iw);
			loaded_offset = 0;
			loaded_status = 0;
			fb_next_image(1);
		} else if (is_playlist(item)) {
			if (current_pl)
				free(current_pl);
			current_pl = strdup(path);
			mvpw_show(fb_progress);
			mvpw_set_timer(fb_progress, fb_osd_update, 500);
			mvpw_hide(widget);
			printf("Show playlist menu\n");
			mvpw_show(playlist_widget);
			mvpw_focus(playlist_widget);
			playlist_clear();
			playlist_play(NULL);
		}
	}
}
Example #11
0
void VlcPluginBase::control_handler(vlc_toolbar_clicked_t clicked)
{
    switch( clicked )
    {
        case clicked_Play:
        {
            playlist_play();
        }
        break;

        case clicked_Pause:
        {
            playlist_pause();
        }
        break;

        case clicked_Stop:
        {
            playlist_stop();
        }
        break;

        case clicked_Fullscreen:
        {
            toggle_fullscreen();
        }
        break;

        case clicked_Mute:
        case clicked_Unmute:
#if 0
        {
            if( p_md )
                libvlc_audio_toggle_mute( p_md );
        }
#endif
        break;

        case clicked_timeline:
#if 0
        {
            /* if a movie is loaded */
            if( p_md )
            {
                int64_t f_length;
                f_length = libvlc_media_player_get_length( p_md ) / 100;

                f_length = (float)f_length *
                        ( ((float)i_xPos-4.0 ) / ( ((float)i_width-8.0)/100) );

                libvlc_media_player_set_time( p_md, f_length );
            }
        }
#endif
        break;

        case clicked_Time:
        {
            /* Not implemented yet*/
        }
        break;

        default: /* button_Unknown */
            fprintf(stderr, "button Unknown!\n");
        break;
    }
}
Example #12
0
bool
playlist_state_restore(const char *line, FILE *fp, GString *buffer,
		       struct playlist *playlist)
{
	int current = -1;
	int seek_time = 0;
	int state = PLAYER_STATE_STOP;
	bool random_mode = false;

	if (!g_str_has_prefix(line, PLAYLIST_STATE_FILE_STATE))
		return false;

	line += sizeof(PLAYLIST_STATE_FILE_STATE) - 1;

	if (strcmp(line, PLAYLIST_STATE_FILE_STATE_PLAY) == 0)
		state = PLAYER_STATE_PLAY;
	else if (strcmp(line, PLAYLIST_STATE_FILE_STATE_PAUSE) == 0)
		state = PLAYER_STATE_PAUSE;

	while ((line = read_text_line(fp, buffer)) != NULL) {
		if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_TIME)) {
			seek_time =
			    atoi(&(line[strlen(PLAYLIST_STATE_FILE_TIME)]));
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_REPEAT)) {
			if (strcmp
			    (&(line[strlen(PLAYLIST_STATE_FILE_REPEAT)]),
			     "1") == 0) {
				playlist_set_repeat(playlist, true);
			} else
				playlist_set_repeat(playlist, false);
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_SINGLE)) {
			if (strcmp
			    (&(line[strlen(PLAYLIST_STATE_FILE_SINGLE)]),
			     "1") == 0) {
				playlist_set_single(playlist, true);
			} else
				playlist_set_single(playlist, false);
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_CONSUME)) {
			if (strcmp
			    (&(line[strlen(PLAYLIST_STATE_FILE_CONSUME)]),
			     "1") == 0) {
				playlist_set_consume(playlist, true);
			} else
				playlist_set_consume(playlist, false);
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_CROSSFADE)) {
			pc_set_cross_fade(atoi(line + strlen(PLAYLIST_STATE_FILE_CROSSFADE)));
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_MIXRAMPDB)) {
			pc_set_mixramp_db(atof(line + strlen(PLAYLIST_STATE_FILE_MIXRAMPDB)));
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_MIXRAMPDELAY)) {
			pc_set_mixramp_delay(atof(line + strlen(PLAYLIST_STATE_FILE_MIXRAMPDELAY)));
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_RANDOM)) {
			random_mode =
				strcmp(line + strlen(PLAYLIST_STATE_FILE_RANDOM),
				       "1") == 0;
		} else if (g_str_has_prefix(line, PLAYLIST_STATE_FILE_CURRENT)) {
			current = atoi(&(line
					 [strlen
					  (PLAYLIST_STATE_FILE_CURRENT)]));
		} else if (g_str_has_prefix(line,
					    PLAYLIST_STATE_FILE_PLAYLIST_BEGIN)) {
			playlist_state_load(fp, buffer, playlist);
		}
	}

	playlist_set_random(playlist, random_mode);

	if (!queue_is_empty(&playlist->queue)) {
		if (!queue_valid_position(&playlist->queue, current))
			current = 0;

		/* enable all devices for the first time; this must be
		   called here, after the audio output states were
		   restored, before playback begins */
		if (state != PLAYER_STATE_STOP)
			pc_update_audio();

		if (state == PLAYER_STATE_STOP /* && config_option */)
			playlist->current = current;
		else if (seek_time == 0)
			playlist_play(playlist, current);
		else
			playlist_seek_song(playlist, current, seek_time);

		if (state == PLAYER_STATE_PAUSE)
			pc_pause();
	}

	return true;
}