[vlc-devel] playlist API

Stephan Assmus stippi at yellowbites.com
Wed Jan 29 17:48:52 CET 2003


Hello all,

I was working on the BeOS playlist handling today, and I have to say I 
find the vlc API in that regard rather clumsy. The thing I have 
implemented is drag-sorting in the playlist window. The API currently 
consists of playlist_Add(), playlist_AddItem() and playlist_Delete(). I 
think, these functions are not enough and/or they do more than they 
should. Here is my proposal for an easier but more powerful API:

playlist_item_t* playlist_ItemAt( int index );
                    // returns NULL if index out of range
int              playlist_AddItem( playlist_item_t* item, int index = -
1 );
                    // returns 1 if successful, otherwise 0
                    // if index = -1, append at end
int              playlist_RemoveItem( playlist_item_t* item );
                    // returns 1 if successful, otherwise 0
                    // does NOT free/delete the item - only removes it 
from list!
playlist_item_t* playlist_RemoveItem( int index );
                    // returns item at index or NULL, if index out of 
range
                    // does NOT free/delete the item - only removes it 
from list
                    // and returns it!

With these four simple functions, any playlist modification is 
possible. The most annoying thing about the current API is, that items 
actually get freed when you remove them. This caused me troubles when 
trying to implement sorting. In my API, no function would do any 
allocating or freeing of the items. That would be left up to the 
caller. The power in my API lies in the fact, that you can disconnect 
playlist items from the list and add them at another index.

While looking through the playlist and other parts of the vlc code, I 
noticed that the source mimics object oriented design, but I think it 
would be much cleaner to read and easier to maintain and some features 
would just fall into place if it actually were C++. But that's just my 
observation, I assume many would disagree about using C++.

An additional playlist_DeleteItem() is still needed, and that function 
should also take care of actually stopping the playback if the deleted 
item happens to be the currently played item. Currently, 
playlist_Delete() does nothing in that regard.

Last but not least, playlist_Add( const char* path ) would be 
convenient to keep arround.

Best regards,
-Stephan




-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>



More information about the vlc-devel mailing list