summaryrefslogtreecommitdiffstats
path: root/Gui
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-02-05 23:02:35 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-02-05 23:02:35 +0000
commit6b5dc1e6123046245b1f76962170c94df4ea9dbe (patch)
tree1ab041d2b8e44c9f6b75f9753939d2e899602cbb /Gui
parentf7b66d5568fc4cad20a734e51428859b148e4c79 (diff)
downloadmpv-6b5dc1e6123046245b1f76962170c94df4ea9dbe.tar.bz2
mpv-6b5dc1e6123046245b1f76962170c94df4ea9dbe.tar.xz
- It adds an option enqueue/noenqueue, so users can choose if they want to
have playlist overwritten by files on commandline or just enqueue them at the end ... - Playtree is finally cleared, as such gui has total control! - Autoplay if files are available on commandline and -enqueue is not set! - Fallback on Playlists finally does work with Gui and even with streaming Playlists! [ Before gui was broken as mplayer.c:playtree tried to have control] patch by Fabian Franz <FabianFranz@gmx.de> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9292 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'Gui')
-rw-r--r--Gui/interface.c156
-rw-r--r--Gui/interface.h3
-rw-r--r--Gui/mplayer/play.c32
-rw-r--r--Gui/mplayer/play.h1
4 files changed, 185 insertions, 7 deletions
diff --git a/Gui/interface.c b/Gui/interface.c
index ab9bc5f1a2..79bf6e1027 100644
--- a/Gui/interface.c
+++ b/Gui/interface.c
@@ -670,7 +670,7 @@ int guiGetEvent( int type,char * arg )
break;
#endif
}
- if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST )
+ //if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore!
{
if ( guiIntfStruct.Filename ) filename=gstrdup( guiIntfStruct.Filename );
else if ( filename ) guiSetFilename( guiIntfStruct.Filename,filename );
@@ -834,29 +834,68 @@ void * gtkSet( int cmd,float fparam, void * vparam )
} else { item->prev=item->next=NULL; plCurrent=plList=item; }
list();
return NULL;
- case gtkGetNextPlItem: // get current item from playlist
+ case gtkInsertPlItem: // add item into playlist after current
if ( plCurrent )
{
+ plItem * curr = plCurrent;
+ item->next=curr->next;
+ if (item->next)
+ item->next->prev=item;
+ item->prev=curr;
+ curr->next=item;
+ plCurrent=plCurrent->next;
+ return plCurrent;
+ }
+ else
+ return gtkSet(gtkAddPlItem,0,(void*)item);
+ return NULL;
+ case gtkGetNextPlItem: // get current item from playlist
+ if ( plCurrent && plCurrent->next)
+ {
plCurrent=plCurrent->next;
- if ( !plCurrent && plList )
+ /*if ( !plCurrent && plList )
{
plItem * next = plList;
while ( next->next ) { if ( !next->next ) break; next=next->next; }
plCurrent=next;
- }
+ }*/
return plCurrent;
}
return NULL;
case gtkGetPrevPlItem:
- if ( plCurrent )
+ if ( plCurrent && plCurrent->prev)
{
plCurrent=plCurrent->prev;
- if ( !plCurrent && plList ) plCurrent=plList;
+ //if ( !plCurrent && plList ) plCurrent=plList;
return plCurrent;
}
return NULL;
+ case gtkSetCurrPlItem: // set current item
+ plCurrent=item;
+ return plCurrent;
case gtkGetCurrPlItem: // get current item
return plCurrent;
+ case gtkDelCurrPlItem: // delete current item
+ {
+ plItem * curr = plCurrent;
+
+ if (!curr)
+ return NULL;
+ if (curr->prev)
+ curr->prev->next=curr->next;
+ if (curr->next)
+ curr->next->prev=curr->prev;
+ if (curr==plList)
+ plList=curr->next;
+ plCurrent=curr->next;
+ // Free it
+ if ( curr->path ) free( curr->path );
+ if ( curr->name ) free( curr->name );
+ free( curr );
+ }
+ mplCurr(); // Instead of using mplNext && mplPrev
+
+ return plCurrent;
case gtkDelPl: // delete list
{
plItem * curr = plList;
@@ -1002,3 +1041,108 @@ void * gtkSet( int cmd,float fparam, void * vparam )
}
return NULL;
}
+
+#define mp_basename(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))
+
+#include "../playtree.h"
+
+//This function adds/inserts one file into the gui playlist
+
+int import_file_into_gui(char* temp, int insert)
+{
+ char *filename, *pathname;
+ plItem * item;
+
+ filename = strdup(mp_basename(temp));
+ pathname = strdup(temp);
+ if (strlen(pathname)-strlen(filename)>0)
+ pathname[strlen(pathname)-strlen(filename)-1]='\0'; // We have some path so remove / at end
+ else
+ pathname[strlen(pathname)-strlen(filename)]='\0';
+ mp_msg(MSGT_PLAYTREE,MSGL_V, "Adding filename %s && pathname %s\n",filename,pathname); //FIXME: Change to MSGL_DBG2 ?
+ item=calloc( 1,sizeof( plItem ) );
+ if (!item)
+ return 0;
+ item->name=filename;
+ item->path=pathname;
+ if (insert)
+ gtkSet( gtkInsertPlItem,0,(void*)item ); // Inserts the item after current, and makes current=item
+ else
+ gtkSet( gtkAddPlItem,0,(void*)item );
+ return 1;
+}
+
+#ifdef NEW_CONFIG
+ #include "../m_option.h"
+ #include "../m_config.h"
+#else
+ #include "../cfgparser.h"
+#endif
+
+// This function imports the initial playtree (based on cmd-line files) into the gui playlist
+// by either:
+// - overwriting gui pl (enqueue=0)
+// - appending it to gui pl (enqueue=1)
+
+int import_initial_playtree_into_gui(play_tree_t* my_playtree, m_config_t* config, int enqueue)
+{
+ play_tree_iter_t* my_pt_iter=NULL;
+ int result=0;
+
+ if (!enqueue) // Delete playlist before "appending"
+ gtkSet(gtkDelPl,0,0);
+
+ if((my_pt_iter=pt_iter_create(&my_playtree,config)))
+ {
+ while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL)
+ {
+ if (import_file_into_gui(filename, 0)) // Add it to end of list
+ result=1;
+ }
+ }
+
+ mplCurr(); // Update filename
+
+ if (!enqueue)
+ filename=guiIntfStruct.Filename; // Backward compatibility; if file is specified on commandline,
+ // gmplayer does directly start in Play-Mode.
+ else
+ filename=NULL;
+
+ return result;
+}
+
+// This function imports and inserts an playtree, that is created "on the fly", for example by
+// parsing some MOV-Reference-File; or by loading an playlist with "File Open"
+//
+// The file which contained the playlist is thereby replaced with it's contents.
+
+int import_playtree_playlist_into_gui(play_tree_t* my_playtree, m_config_t* config)
+{
+ play_tree_iter_t* my_pt_iter=NULL;
+ int result=0;
+ plItem * save=(plItem*)gtkSet( gtkGetCurrPlItem, 0, 0); // Save current item
+
+ if((my_pt_iter=pt_iter_create(&my_playtree,config)))
+ {
+ while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL)
+ {
+ if (import_file_into_gui(filename, 1)) // insert it into the list and set plCurrent=new item
+ result=1;
+ }
+ pt_iter_destroy(&my_pt_iter);
+ }
+
+ if (save)
+ gtkSet(gtkSetCurrPlItem, 0, (void*)save);
+ else
+ gtkSet(gtkSetCurrPlItem, 0, (void*)plList); // go to head, if plList was empty before
+
+ if (save && result)
+ gtkSet(gtkDelCurrPlItem, 0, 0);
+
+ mplCurr(); // Update filename
+ filename=NULL;
+
+ return result;
+}
diff --git a/Gui/interface.h b/Gui/interface.h
index b2be1f8b82..3d3ceb99a0 100644
--- a/Gui/interface.h
+++ b/Gui/interface.h
@@ -196,6 +196,9 @@ extern char * fsHistory[fsPersistant_MaxPos];
#define gtkSetFontEncoding 20
#define gtkSetFontAutoScale 21
#define gtkSetSubEncoding 22
+#define gtkDelCurrPlItem 23
+#define gtkInsertPlItem 24
+#define gtkSetCurrPlItem 25
extern float gtkEquChannels[6][10];
diff --git a/Gui/mplayer/play.c b/Gui/mplayer/play.c
index f7ad980432..147674bba0 100644
--- a/Gui/mplayer/play.c
+++ b/Gui/mplayer/play.c
@@ -69,7 +69,7 @@ void mplEnd( void )
{
plItem * next;
- if ( !mplGotoTheNext ) { mplGotoTheNext=1; return; }
+ if ( !mplGotoTheNext && guiIntfStruct.Playing) { mplGotoTheNext=1; return; }
if ( guiIntfStruct.Playing && (next=gtkSet( gtkGetNextPlItem,0,NULL )) && plLastPlayed != next )
{
@@ -268,6 +268,36 @@ void mplSetFileName( char * dir,char * name,int type )
gfree( (void **)&guiIntfStruct.Subtitlename );
}
+void mplCurr( void )
+{
+ plItem * curr;
+ int stop = 0;
+
+ if ( guiIntfStruct.Playing == 2 ) return;
+ switch ( guiIntfStruct.StreamType )
+ {
+#ifdef USE_DVDREAD
+ case STREAMTYPE_DVD:
+ break;
+#endif
+#ifdef HAVE_VCD
+ case STREAMTYPE_VCD:
+ break;
+#endif
+ default:
+ if ( (curr=gtkSet( gtkGetCurrPlItem,0,NULL)) )
+ {
+ mplSetFileName( curr->path,curr->name,STREAMTYPE_FILE );
+ mplGotoTheNext=0;
+ break;
+ }
+ return;
+ }
+ if ( stop ) mplEventHandling( evStop,0 );
+ if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 );
+}
+
+
void mplPrev( void )
{
plItem * prev;
diff --git a/Gui/mplayer/play.h b/Gui/mplayer/play.h
index 9b1dd25e9e..b7c3c58a3b 100644
--- a/Gui/mplayer/play.h
+++ b/Gui/mplayer/play.h
@@ -13,6 +13,7 @@ extern void mplPause( void );
extern void mplState( void );
extern void mplPrev( void );
extern void mplNext( void );
+extern void mplCurr( void );
extern void mplIncAudioBufDelay( void );
extern void mplDecAudioBufDelay( void );