static int playlist_insert_func(void *param) { if (((intptr_t)param == PLAYLIST_REPLACE) && !warn_on_pl_erase()) return 0; add_to_playlist((intptr_t)param, false); return 0; }
void add_to_playlist_recursive ( songdata *list, songdata_song *position, songdata_song *file ) { char *prevpwd = NULL; songdata *templist = NULL; if ( ! ( file->flags & F_DIR ) ) return; templist = malloc( sizeof ( songdata ) ); memset(templist, 0, sizeof(songdata)); prevpwd = getcwd ( NULL, 0 ); songdata_read_mp3_list ( templist, file->fullpath, L_NEW ); if (templist->selected && !strncmp ( templist->selected->filename, "../", 3 ) ) templist->selected = templist->head->next; // skip ../ entry while ( templist->selected ) { if ( templist->selected->flags & F_DIR ) add_to_playlist_recursive ( list, list->tail, templist->selected ); else if ( ! ( templist->selected->flags & F_PLAYLIST ) ) add_to_playlist ( list, list->tail, templist->selected ); templist->selected = songdata_next_valid ( templist, templist->selected->next, KEY_DOWN ); } songdata_clear ( templist ); free ( templist ); if(chdir ( prevpwd ) != 0){ //TODO Log this error } free ( prevpwd ); }
static void add_to_playlist (GPtrArray * playlist, const gchar * filename) { GDir *dir; gchar *uri; if (gst_uri_is_valid (filename)) { g_ptr_array_add (playlist, g_strdup (filename)); return; } if ((dir = g_dir_open (filename, 0, NULL))) { const gchar *entry; /* FIXME: sort entries for each directory? */ while ((entry = g_dir_read_name (dir))) { gchar *path; path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL); add_to_playlist (playlist, path); g_free (path); } g_dir_close (dir); return; } uri = gst_filename_to_uri (filename, NULL); if (uri != NULL) g_ptr_array_add (playlist, uri); else g_warning ("Could not make URI out of filename '%s'", filename); }
static void on_search_results_row_activate (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { add_to_playlist (tree_view, NULL); }
bool catalog_add_to_a_playlist(const char* sel, int sel_attr, bool new_playlist, char *m3u8name) { int result; char playlist[MAX_PATH]; if (in_add_to_playlist) return false; if (initialize_catalog() == -1) return false; if (new_playlist) { size_t len; if (m3u8name == NULL) { /*If sel is a folder, we prefill the text field with its name*/ const char *name = strrchr(sel, '/'); snprintf(playlist, MAX_PATH, "%s/%s.m3u8", playlist_dir, (name!=NULL && (sel_attr & ATTR_DIRECTORY))?name+1:""); } else strcpy(playlist, m3u8name); len = strlen(playlist); if(len > 4 && !strcasecmp(&playlist[len-4], ".m3u")) strcat(playlist, "8"); else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8")) strcat(playlist, ".m3u8"); if (kbd_input(playlist, MAX_PATH)) return false; } else { in_add_to_playlist = true; result = display_playlists(playlist, false); in_add_to_playlist = false; if (result == -1) return false; } if (add_to_playlist(playlist, new_playlist, sel, sel_attr) == 0) return true; else return false; }
void add_selected_to_playlist(void) { int i; DEBUG_MSG("add_selected_to_playlist"); for(i=0; i<row_count; i++) { struct entry *d = (struct entry*)gtk_clist_get_row_data(GTK_CLIST(file_list), i); if( d->selected ) { add_to_playlist(i); } } }
void add_selected_to_playlist_and_play(void) { int i; int playnow = 1; for(i=0; i<row_count; i++) { struct entry *d = (struct entry*)gtk_clist_get_row_data(GTK_CLIST(file_list), i); if( d->selected ) { if (!playnow) add_to_playlist(i); else { playnow = 0; add_to_playlist_and_play(i); } } } }
static void add_to_playlist (GPtrArray * playlist, const gchar * filename) { GDir *dir; gchar *uri; if (gst_uri_is_valid (filename)) { g_ptr_array_add (playlist, g_strdup (filename)); return; } if ((dir = g_dir_open (filename, 0, NULL))) { const gchar *entry; GList *l, *files = NULL; while ((entry = g_dir_read_name (dir))) { gchar *path; path = g_build_filename (filename, entry, NULL); files = g_list_insert_sorted (files, path, compare); } g_dir_close (dir); for (l = files; l != NULL; l = l->next) { gchar *path = (gchar *) l->data; add_to_playlist (playlist, path); g_free (path); } g_list_free (files); return; } uri = gst_filename_to_uri (filename, NULL); if (uri != NULL) g_ptr_array_add (playlist, uri); else g_warning ("Could not make URI out of filename '%s'", filename); }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean verbose = FALSE; gboolean print_version = FALSE; gboolean interactive = TRUE; gboolean gapless = FALSE; gboolean shuffle = FALSE; gdouble volume = -1; gchar **filenames = NULL; gchar *audio_sink = NULL; gchar *video_sink = NULL; gchar **uris; gchar *flags = NULL; guint num, i; GError *err = NULL; GOptionContext *ctx; gchar *playlist_file = NULL; GOptionEntry options[] = { {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Output status information and property notifications"), NULL}, {"flags", 0, 0, G_OPTION_ARG_STRING, &flags, N_("Control playback behaviour setting playbin 'flags' property"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print version information and exit"), NULL}, {"videosink", 0, 0, G_OPTION_ARG_STRING, &video_sink, N_("Video sink to use (default is autovideosink)"), NULL}, {"audiosink", 0, 0, G_OPTION_ARG_STRING, &audio_sink, N_("Audio sink to use (default is autoaudiosink)"), NULL}, {"gapless", 0, 0, G_OPTION_ARG_NONE, &gapless, N_("Enable gapless playback"), NULL}, {"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle, N_("Shuffle playlist"), NULL}, {"no-interactive", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &interactive, N_("Disable interactive control via the keyboard"), NULL}, {"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume, N_("Volume"), NULL}, {"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file, N_("Playlist file containing input media files"), NULL}, {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Do not print any output (apart from errors)"), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; setlocale (LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_set_prgname ("gst-play-" GST_API_VERSION); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); g_option_context_free (ctx); g_clear_error (&err); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION); g_print ("%s\n", version_str); g_print ("%s\n", GST_PACKAGE_ORIGIN); g_free (version_str); g_free (audio_sink); g_free (video_sink); g_free (playlist_file); return 0; } playlist = g_ptr_array_new (); if (playlist_file != NULL) { gchar *playlist_contents = NULL; gchar **lines = NULL; if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) { lines = g_strsplit (playlist_contents, "\n", 0); num = g_strv_length (lines); for (i = 0; i < num; i++) { if (lines[i][0] != '\0') { GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]); add_to_playlist (playlist, lines[i]); } } g_strfreev (lines); g_free (playlist_contents); } else { g_printerr ("Could not read playlist: %s\n", err->message); g_clear_error (&err); } g_free (playlist_file); playlist_file = NULL; } if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) { g_printerr (_("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."), "gst-play-" GST_API_VERSION); g_printerr ("\n\n"), g_printerr ("%s\n\n", _("You must provide at least one filename or URI to play.")); /* No input provided. Free array */ g_ptr_array_free (playlist, TRUE); g_free (audio_sink); g_free (video_sink); return 1; } /* fill playlist */ if (filenames != NULL && *filenames != NULL) { num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); } num = playlist->len; g_ptr_array_add (playlist, NULL); uris = (gchar **) g_ptr_array_free (playlist, FALSE); if (shuffle) shuffle_uris (uris, num); /* prepare */ play = play_new (uris, audio_sink, video_sink, gapless, volume, verbose, flags); if (play == NULL) { g_printerr ("Failed to create 'playbin' element. Check your GStreamer installation.\n"); return EXIT_FAILURE; } if (interactive) { if (gst_play_kb_set_key_handler (keyboard_cb, play)) { g_print (_("Press 'k' to see a list of keyboard shortcuts.\n")); atexit (restore_terminal); } else { g_print ("Interactive keyboard handling in terminal not available.\n"); } } /* play */ do_play (play); /* clean up */ play_free (play); g_free (audio_sink); g_free (video_sink); g_print ("\n"); gst_deinit (); return 0; }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean print_version = FALSE; gboolean gapless = FALSE; gchar **filenames = NULL; gchar *audio_sink = NULL; gchar *video_sink = NULL; gchar **uris; guint num, i; GError *err = NULL; GOptionContext *ctx; GOptionEntry options[] = { {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print version information and exit"), NULL}, {"videosink", 0, 0, G_OPTION_ARG_STRING, &video_sink, N_("Video sink to use (default is autovideosink)"), NULL}, {"audiosink", 0, 0, G_OPTION_ARG_STRING, &audio_sink, N_("Audio sink to use (default is autoaudiosink)"), NULL}, {"gapless", 0, 0, G_OPTION_ARG_NONE, &gapless, N_("Enable gapless playback"), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_set_prgname ("gst-play-" GST_API_VERSION); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION); g_print ("%s\n", version_str); g_print ("%s\n", GST_PACKAGE_ORIGIN); g_free (version_str); return 0; } if (filenames == NULL || *filenames == NULL) { g_printerr (_("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."), "gst-play-" GST_API_VERSION); g_printerr ("\n\n"), g_printerr ("%s\n\n", _("You must provide at least one filename or URI to play.")); return 1; } playlist = g_ptr_array_new (); /* fill playlist */ num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); g_ptr_array_add (playlist, NULL); /* play */ uris = (gchar **) g_ptr_array_free (playlist, FALSE); play = play_new (uris, audio_sink, video_sink, gapless); do_play (play); /* clean up */ play_free (play); return 0; }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean print_version = FALSE; gboolean interactive = FALSE; /* FIXME: maybe enable by default? */ gboolean shuffle = FALSE; gdouble volume = 1.0; gchar **filenames = NULL; gchar **uris; guint num, i; GError *err = NULL; GOptionContext *ctx; gchar *playlist_file = NULL; GOptionEntry options[] = { {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, "Print version information and exit", NULL}, {"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle, "Shuffle playlist", NULL}, {"interactive", 0, 0, G_OPTION_ARG_NONE, &interactive, "Interactive control via keyboard", NULL}, {"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume, "Volume", NULL}, {"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file, "Playlist file containing input media files", NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; g_set_prgname ("gst-play"); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), "1.0"); g_print ("%s\n", version_str); g_free (version_str); g_free (playlist_file); return 0; } playlist = g_ptr_array_new (); if (playlist_file != NULL) { gchar *playlist_contents = NULL; gchar **lines = NULL; if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) { lines = g_strsplit (playlist_contents, "\n", 0); num = g_strv_length (lines); for (i = 0; i < num; i++) { if (lines[i][0] != '\0') { GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]); add_to_playlist (playlist, lines[i]); } } g_strfreev (lines); g_free (playlist_contents); } else { g_printerr ("Could not read playlist: %s\n", err->message); g_clear_error (&err); } g_free (playlist_file); playlist_file = NULL; } if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) { g_printerr ("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ...", "gst-play"); g_printerr ("\n\n"), g_printerr ("%s\n\n", "You must provide at least one filename or URI to play."); /* No input provided. Free array */ g_ptr_array_free (playlist, TRUE); return 1; } /* fill playlist */ if (filenames != NULL && *filenames != NULL) { num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); } num = playlist->len; g_ptr_array_add (playlist, NULL); uris = (gchar **) g_ptr_array_free (playlist, FALSE); if (shuffle) shuffle_uris (uris, num); /* prepare */ play = play_new (uris, volume); if (interactive) { if (gst_play_kb_set_key_handler (keyboard_cb, play)) { atexit (restore_terminal); } else { g_print ("Interactive keyboard handling in terminal not available.\n"); } } /* play */ do_play (play); /* clean up */ play_free (play); g_print ("\n"); return 0; }
static void on_menu_item_add_to_playlist (GtkWidget *menu_item, GtkTreeView *tree_view) { add_to_playlist (tree_view, NULL); }
static LRESULT CALLBACK WMCOPYWNDPROC(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if( uMsg == WM_QUIT ) { PostQuitMessage( 0 ); } else if( uMsg == WM_COPYDATA ) { COPYDATASTRUCT *pwm_data = (COPYDATASTRUCT*)lParam; intf_thread_t *intf = (intf_thread_t *)(uintptr_t) GetWindowLongPtr( hwnd, GWLP_USERDATA ); if( intf == NULL ) return 0; /* XXX: is this even possible? */ /* Add files to the playlist */ if( pwm_data->lpData ) { char **ppsz_argv; vlc_ipc_data_t *p_data = (vlc_ipc_data_t *)pwm_data->lpData; size_t i_data = 0; int i_argc = p_data->argc, i_opt, i_options; ppsz_argv = vlc_alloc( i_argc, sizeof(char *) ); for( i_opt = 0; i_opt < i_argc; i_opt++ ) { ppsz_argv[i_opt] = p_data->data + i_data + sizeof(size_t); i_data += sizeof(size_t) + *((size_t *)(p_data->data + i_data)); } for( i_opt = 0; i_opt < i_argc; i_opt++ ) { i_options = 0; /* Count the input options */ while( i_opt + i_options + 1 < i_argc && *ppsz_argv[ i_opt + i_options + 1 ] == ':' ) { i_options++; } #warning URI conversion must be done in calling process instead! /* FIXME: This breaks relative paths if calling vlc.exe is * started from a different working directory. */ char *psz_URI = NULL; if( strstr( ppsz_argv[i_opt], "://" ) == NULL ) psz_URI = vlc_path2uri( ppsz_argv[i_opt], NULL ); add_to_playlist(intf, (psz_URI != NULL) ? psz_URI : ppsz_argv[i_opt], (i_opt == 0 && !p_data->enqueue), i_options, (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL )); i_opt += i_options; free( psz_URI ); } free( ppsz_argv ); } } return DefWindowProc( hwnd, uMsg, wParam, lParam ); }
static int playlist_queue_func(void *param) { add_to_playlist((intptr_t)param, true); return 0; }
static void on_menu_item_add_to_new_playlist (GtkWidget *menu_item, GtkTreeView *tree_view) { add_to_playlist (tree_view, last_search_query); }
void add_to_playlist_and_play(gint row) { xmms_remote_playlist_clear(cue_gp.xmms_session); add_to_playlist(row); xmms_remote_set_playlist_pos(cue_gp.xmms_session, 0); xmms_remote_play(cue_gp.xmms_session); }
void gui_input_filelist(int c) { int alt = 0; int n; songdata_song *ftmp; if (c == 27) { alt = 1; c = getch(); } switch (c) { case KEY_ENTER: case '\n': case '\r': typed_letters[0] = '\0'; if ((mp3list->selected->flags & F_DIR)) { if (!alt) { // change to another directory if (!strcmp("../", mp3list->selected->filename)) { char * filename = strdup(dirstack_filename()); char * fullpath = strdup(dirstack_fullpath()); dirstack_pop(); songdata_read_mp3_list(mp3list, fullpath, L_NEW); while (strcmp(mp3list->selected->filename, filename)) window_input(filelist_window, KEY_DOWN); free(filename); free(fullpath); } else { if (!(mp3list->flags & F_VIRTUAL)) dirstack_push(mp3list->from, mp3list->selected->filename); songdata_read_mp3_list(mp3list, mp3list->selected->fullpath, L_NEW); } gui_update_filelist(); } else { // add songs from directory if (previous_selected) free(previous_selected); previous_selected = strdup(mp3list->selected->fullpath); if ((!(mp3list->flags & F_VIRTUAL)) & (strcmp("../", mp3list->selected->fullpath))) { add_to_playlist_recursive(playlist, playlist->tail, mp3list->selected); gui_update_playlist(); } } } else if (mp3list->selected->flags & F_PLAYLIST) { if (!alt) { dirstack_push(mp3list->from, mp3list->selected->filename); songdata_read_mp3_list(mp3list, mp3list->selected->fullpath, L_NEW); gui_update_filelist(); } else { add_to_playlist_recursive(playlist, playlist->tail, mp3list->selected); gui_update_playlist(); } } else // normal mp3 if (strcmp(previous_selected, mp3list->selected->fullpath)) { if (previous_selected) free(previous_selected); previous_selected = strdup(mp3list->selected->fullpath); if (!alt) add_to_playlist(playlist, playlist->tail, mp3list->selected); else add_to_playlist(playlist, playlist->selected, mp3list->selected); gui_update_playlist(); if (conf->c_flags & C_FADVANCE) { window_input(filelist_window, KEY_DOWN); } } break; case KEY_LEFT: // leave directory if (!dirstack_empty()) { char *filename = strdup(dirstack_filename()); char *fullpath = strdup(dirstack_fullpath()); dirstack_pop(); songdata_read_mp3_list(mp3list, fullpath, L_NEW); while (strcmp(mp3list->selected->filename, filename)) { window_input_list(filelist_window, KEY_DOWN); } gui_update_filelist(); gui_update_info(); free(filename); free(fullpath); } break; case KEY_RIGHT: // enter directory if ((mp3list->selected->flags & (F_DIR | F_PLAYLIST)) && (strncmp(mp3list->selected->filename, "../", 3))) { if (!(mp3list->flags & F_VIRTUAL)) { dirstack_push(mp3list->from, mp3list->selected->filename); } songdata_read_mp3_list(mp3list, mp3list->selected->fullpath, L_NEW); if (mp3list->head) { window_input_list(filelist_window, KEY_DOWN); } } gui_update_filelist(); gui_update_info(); break; case KEY_IC: if (!((mp3list->selected->flags & F_DIR) | (mp3list->selected->flags & F_PLAYLIST))) if (strcmp(previous_selected, mp3list->selected->fullpath)) { // we dont want to add the last file multiple times if (previous_selected) free(previous_selected); previous_selected = strdup(mp3list->selected->fullpath); if (playlist->playing) add_to_playlist(playlist, playlist->playing, mp3list->selected); else add_to_playlist(playlist, playlist->selected, mp3list->selected); if (conf->c_flags & C_FADVANCE) { window_input(filelist_window, KEY_DOWN); gui_update_filelist(); gui_update_info(); } gui_update_playlist(); } break; case 'a'...'z': case 'A'...'Z': case '0'...'9': case '.': case ' ': ftmp = mp3list->head; n = 0; time_t time_now = time(NULL); if (difftime(time_now, typed_letters_last_activity) > 10) { typed_letters[0] = '\0'; } if (strlen(typed_letters) < 4) { // add the letter to the string and reset the timeout strcat(typed_letters, (char *) &c); } while (strncasecmp(ftmp->filename, typed_letters, strlen(typed_letters)) != 0) { if (ftmp == mp3list->tail) { ftmp = NULL; break; } ftmp = ftmp->next; n++; } if (ftmp) { // match found mp3list->selected = ftmp; mp3list->where = n; gui_update_filelist(); } typed_letters_last_activity = time_now; break; case KEY_BACKSPACE: if (strlen(typed_letters) >= 1) { typed_letters[strlen(typed_letters) - 1] = '\0'; typed_letters_last_activity = time(NULL); } break; default: window_input(filelist_window, c); break; } }