summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mplayer.c15
-rw-r--r--playtreeparser.c28
2 files changed, 36 insertions, 7 deletions
diff --git a/mplayer.c b/mplayer.c
index c20cc0bfce..796bb6e403 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -582,6 +582,8 @@ static int libmpdemux_was_interrupted(int eof) {
int playtree_add_playlist(play_tree_t* entry)
{
+ play_tree_add_bpf(entry,filename);
+
#ifdef HAVE_NEW_GUI
if (use_gui) {
if (entry) {
@@ -759,9 +761,22 @@ int gui_no_filename=0;
use_gui=0;
}
if (use_gui && playtree_iter){
+ char* cwd;
// Remove Playtree and Playtree-Iter from memory as its not used by gui
play_tree_iter_free(playtree_iter);
playtree_iter=NULL;
+
+ if ((cwd=get_current_dir_name()))
+ {
+ cwd=(char*)realloc(cwd, strlen(cwd)+2);
+ if (cwd)
+ {
+ strcat(cwd, "/");
+ // Prefix relative paths with current working directory
+ play_tree_add_bpf(playtree, cwd);
+ free(cwd);
+ }
+ }
// Import initital playtree into gui
import_initial_playtree_into_gui(playtree, mconfig, enqueue);
}
diff --git a/playtreeparser.c b/playtreeparser.c
index a0d74556a0..63da140782 100644
--- a/playtreeparser.c
+++ b/playtreeparser.c
@@ -493,6 +493,26 @@ play_tree_add_basepath(play_tree_t* pt, char* bp) {
}
}
+// Wrapper for play_tree_add_basepath (add base path from file)
+void play_tree_add_bpf(play_tree_t* pt, char* filename)
+{
+ char *ls, *file;
+
+ if (pt && filename)
+ {
+ file = strdup(filename);
+ if (file)
+ {
+ ls = strrchr(file,PATH_SEP);
+ if(ls) {
+ ls[1] = '\0';
+ play_tree_add_basepath(pt,file);
+ }
+ free(file);
+ }
+ }
+}
+
play_tree_t*
parse_playlist_file(char* file) {
stream_t *stream;
@@ -517,13 +537,7 @@ parse_playlist_file(char* file) {
mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Warning error while closing playlist file %s : %s\n",file,strerror(errno));
free_stream(stream);
- if(ret) {
- char* ls = strrchr(file,PATH_SEP);
- if(ls) {
- ls[1] = '\0';
- play_tree_add_basepath(ret,file);
- }
- }
+ play_tree_add_bpf(ret, file);
return ret;