Mercurial > mplayer.hg
changeset 6661:dc61b6b159e4
Add support for m3u playlists as generated by eg recent versions of winamp.
author | atmos4 |
---|---|
date | Sun, 07 Jul 2002 00:00:04 +0000 |
parents | f8d1c9ab777a |
children | f8e25756a5ec |
files | playtreeparser.c |
diffstat | 1 files changed, 51 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/playtreeparser.c Sat Jul 06 15:23:20 2002 +0000 +++ b/playtreeparser.c Sun Jul 07 00:00:04 2002 +0000 @@ -321,11 +321,57 @@ } play_tree_t* +parse_m3u(play_tree_parser_t* p) { + char* line; + play_tree_t *list = NULL, *entry = NULL; + + mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying extended m3u playlist...\n"); + line = play_tree_parser_get_line(p); + strstrip(line); + if(strcasecmp(line,"#EXTM3U")) + return NULL; + mp_msg(MSGT_PLAYTREE,MSGL_V,"Detected extended m3u playlist format\n"); + play_tree_parser_stop_keeping(p); + + while((line = play_tree_parser_get_line(p)) != NULL) { + strstrip(line); + if(line[0] == '\0') + continue; + /* EXTM3U files contain such lines: + * #EXTINF:<seconds>, <title> + * followed by a line with the filename + * for now we have no place to put that + * so we just skip that extra-info ::atmos + */ + if(line[0] == '#') { +#if 0 /* code functional */ + if(strncasecmp(line,"#EXTINF:",8) == 0) { + mp_msg(MSGT_PLAYTREE,MSGL_INFO,"[M3U] Duration: %dsec Title: %s\n", + strtol(line+8,&line,10), line+2); + } +#endif + continue; + } + entry = play_tree_new(); + play_tree_add_file(entry,line); + if(!list) + list = entry; + else + play_tree_append_entry(list,entry); + } + + if(!list) return NULL; + entry = play_tree_new(); + play_tree_set_child(entry,list); + return entry; +} + +play_tree_t* parse_textplain(play_tree_parser_t* p) { char* line; play_tree_t *list = NULL, *entry = NULL; - mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying plaintext...\n"); + mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying plaintext playlist...\n"); play_tree_parser_stop_keeping(p); while((line = play_tree_parser_get_line(p)) != NULL) { @@ -442,6 +488,10 @@ if(tree) break; play_tree_parser_reset(p); + tree = parse_m3u(p); + if(tree) break; + play_tree_parser_reset(p); + // Here come the others formats ( textplain must stay the last one ) tree = parse_textplain(p); if(tree) break;