diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2011-07-20 14:11:15 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2011-07-20 14:11:15 +0000 |
commit | 97a4c1efa473e40b4dd7287571f3b1c9caaba97d (patch) | |
tree | 384bb5b81d5c4c5b6098bff835af9a7cc75161de /apps/playlist_catalog.c | |
parent | 4983d052a0d73340d09086a796b4ccbb45dfd88b (diff) | |
download | rockbox-97a4c1efa473e40b4dd7287571f3b1c9caaba97d.tar.gz rockbox-97a4c1efa473e40b4dd7287571f3b1c9caaba97d.zip |
FS#11808 - Major playlist handling changes (on disk playlists)
* Playlists are treated similar to directories in the browser, they now open in the viewer when selected instead of automatically starting the playlist.
* Make the "Playlists" main menu item useful, it now displays the playlist catalog (and has been renamed accordingly)
* Default to storing playlists in the catalog
* Add a UI to move the catalog directory
(other minor stuff too)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30177 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playlist_catalog.c')
-rw-r--r-- | apps/playlist_catalog.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 9d4d707c08..3687681b66 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c | |||
@@ -43,6 +43,8 @@ | |||
43 | #include "debug.h" | 43 | #include "debug.h" |
44 | #include "playlist_catalog.h" | 44 | #include "playlist_catalog.h" |
45 | #include "talk.h" | 45 | #include "talk.h" |
46 | #include "playlist_viewer.h" | ||
47 | #include "bookmark.h" | ||
46 | 48 | ||
47 | /* Use for recursive directory search */ | 49 | /* Use for recursive directory search */ |
48 | struct add_track_context { | 50 | struct add_track_context { |
@@ -59,9 +61,9 @@ static int playlist_dir_length; | |||
59 | static bool playlist_dir_exists = false; | 61 | static bool playlist_dir_exists = false; |
60 | 62 | ||
61 | /* Retrieve playlist directory from config file and verify it exists */ | 63 | /* Retrieve playlist directory from config file and verify it exists */ |
64 | static bool initialized = false; | ||
62 | static int initialize_catalog(void) | 65 | static int initialize_catalog(void) |
63 | { | 66 | { |
64 | static bool initialized = false; | ||
65 | 67 | ||
66 | if (!initialized) | 68 | if (!initialized) |
67 | { | 69 | { |
@@ -110,6 +112,27 @@ static int initialize_catalog(void) | |||
110 | return 0; | 112 | return 0; |
111 | } | 113 | } |
112 | 114 | ||
115 | void catalog_set_directory(const char* directory) | ||
116 | { | ||
117 | if (directory == NULL) | ||
118 | { | ||
119 | global_settings.playlist_catalog_dir[0] = '\0'; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | strcpy(global_settings.playlist_catalog_dir, directory); | ||
124 | } | ||
125 | initialized = false; | ||
126 | initialize_catalog(); | ||
127 | } | ||
128 | |||
129 | const char* catalog_get_directory(void) | ||
130 | { | ||
131 | if (initialize_catalog() == -1) | ||
132 | return ""; | ||
133 | return playlist_dir; | ||
134 | } | ||
135 | |||
113 | /* Display all playlists in catalog. Selected "playlist" is returned. | 136 | /* Display all playlists in catalog. Selected "playlist" is returned. |
114 | If "view" mode is set then we're not adding anything into playlist. */ | 137 | If "view" mode is set then we're not adding anything into playlist. */ |
115 | static int display_playlists(char* playlist, bool view) | 138 | static int display_playlists(char* playlist, bool view) |
@@ -126,6 +149,8 @@ static int display_playlists(char* playlist, bool view) | |||
126 | browse.buf = selected_playlist; | 149 | browse.buf = selected_playlist; |
127 | browse.bufsize = sizeof(selected_playlist); | 150 | browse.bufsize = sizeof(selected_playlist); |
128 | 151 | ||
152 | restart: | ||
153 | browse.flags &= ~BROWSE_SELECTED; | ||
129 | rockbox_browse(&browse); | 154 | rockbox_browse(&browse); |
130 | 155 | ||
131 | if (browse.flags & BROWSE_SELECTED) | 156 | if (browse.flags & BROWSE_SELECTED) |
@@ -135,9 +160,12 @@ static int display_playlists(char* playlist, bool view) | |||
135 | 160 | ||
136 | if (view) | 161 | if (view) |
137 | { | 162 | { |
138 | char *filename = strrchr(selected_playlist, '/')+1; | 163 | |
139 | /* In view mode, selecting a playlist starts playback */ | 164 | if (!bookmark_autoload(selected_playlist)) |
140 | ft_play_playlist(selected_playlist, playlist_dir, filename); | 165 | { |
166 | if (playlist_viewer_ex(selected_playlist) == PLAYLIST_VIEWER_CANCEL) | ||
167 | goto restart; | ||
168 | } | ||
141 | result = 0; | 169 | result = 0; |
142 | } | 170 | } |
143 | else | 171 | else |
@@ -311,8 +339,6 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr, | |||
311 | snprintf(playlist, MAX_PATH, "%s/%s.m3u8", | 339 | snprintf(playlist, MAX_PATH, "%s/%s.m3u8", |
312 | playlist_dir, | 340 | playlist_dir, |
313 | (name!=NULL && (sel_attr & ATTR_DIRECTORY))?name+1:""); | 341 | (name!=NULL && (sel_attr & ATTR_DIRECTORY))?name+1:""); |
314 | if (kbd_input(playlist, MAX_PATH)) | ||
315 | return false; | ||
316 | } | 342 | } |
317 | else | 343 | else |
318 | strcpy(playlist, m3u8name); | 344 | strcpy(playlist, m3u8name); |
@@ -323,6 +349,9 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr, | |||
323 | strcat(playlist, "8"); | 349 | strcat(playlist, "8"); |
324 | else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8")) | 350 | else if(len <= 5 || strcasecmp(&playlist[len-5], ".m3u8")) |
325 | strcat(playlist, ".m3u8"); | 351 | strcat(playlist, ".m3u8"); |
352 | |||
353 | if (kbd_input(playlist, MAX_PATH)) | ||
354 | return false; | ||
326 | } | 355 | } |
327 | else | 356 | else |
328 | { | 357 | { |