Mercurial > mplayer.hg
changeset 35461:b7696c82c72d
Fix various issues with a playlist change.
While playing, allow adding files to the list. If the current file and
its position in the list don't change, playback continues. With a change
of the current file or during stop mode, playback starts with track 1
again.
It also fixes a wrong track number after a change which has been
reported by Hans-Dieter Kosch, hdkosch kabelbw de.
author | ib |
---|---|
date | Sun, 02 Dec 2012 00:44:03 +0000 |
parents | 7d1d7f783975 |
children | e671bb33230f |
files | gui/ui/gtk/playlist.c |
diffstat | 1 files changed, 31 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/ui/gtk/playlist.c Sun Dec 02 00:42:13 2012 +0000 +++ b/gui/ui/gtk/playlist.c Sun Dec 02 00:44:03 2012 +0000 @@ -36,6 +36,7 @@ #include "gui/ui/widgets.h" #include "gui/util/list.h" #include "gui/util/mem.h" +#include "gui/util/string.h" #include "playlist.h" #include "tools.h" @@ -193,8 +194,16 @@ { case 1: // ok { - int i; - plItem * item; + int pos, i; + plItem curr, * item, * old; + item = listMgr( PLAYLIST_ITEM_GET_CURR,0 ); + if (item) + { + curr.path = gstrdup(item->path); + curr.name = gstrdup(item->name); + } + else curr.path = curr.name = NULL; + pos = (int) listMgr( PLAYLIST_ITEM_GET_POS,item ); listMgr( PLAYLIST_DELETE,0 ); for ( i=0;i<NrOfSelected;i++ ) { @@ -208,15 +217,30 @@ if ( !item->path ) item->path = strdup( text[1] ); listMgr( PLAYLIST_ITEM_APPEND,item ); } - item = listMgr( PLAYLIST_ITEM_GET_CURR,0 ); + item = listMgr( PLAYLIST_GET,0 ); if ( item ) { - uiSetFile( item->path,item->name,STREAMTYPE_FILE ); -// setddup( &guiInfo.Filename,item->path,item->name ); -// guiInfo.NewPlay=GUI_FILE_NEW; -// guiInfo.StreamType=STREAMTYPE_FILE; + if ( guiInfo.Playing && curr.name && pos ) + { + old = listMgr( PLAYLIST_ITEM_FIND,&curr ); + if ( old && ( pos == (int) listMgr( PLAYLIST_ITEM_GET_POS,old ) ) ) + { + listMgr( PLAYLIST_ITEM_SET_CURR,old ); + item = NULL; + } + } + if ( item ) + { + uiUnsetFile(); + uiSetFile( item->path,item->name,STREAMTYPE_FILE ); + guiInfo.NewPlay = GUI_FILE_NEW; + guiInfo.PlaylistNext = 0; + guiInfo.Track = 1; + } } else if (isPlaylistStreamtype && !guiInfo.Playing) uiUnsetFile(); + free(curr.path); + free(curr.name); } case 0: // cancel HidePlayList();