mirror of
https://github.com/videolan/vlc.git
synced 2025-01-26 09:36:25 +08:00
* configure.ac : Added new folders
* New playlist import/export system: -export plugin in misc/playlist (contains one module for each file type) -open plugin = special demuxer2, that can be opened from the command line or the graphical interface. NB: the demuxer "playlist" is forced to earn speed, but this does not work yet, as we have a demux2 * modules/gui/wxwindows: use the new import/export. * src/playlist/group.c : fixed boundary check * src/playlist/item-ext.c: correctly reset stuff when clearing the playlist
This commit is contained in:
parent
0bbccbb10f
commit
5dc722b554
@ -1,5 +1,5 @@
|
||||
dnl Autoconf settings for vlc
|
||||
dnl $Id: configure.ac,v 1.148 2004/01/09 18:32:03 gbazin Exp $
|
||||
dnl $Id: configure.ac,v 1.149 2004/01/11 00:45:06 zorglub Exp $
|
||||
|
||||
AC_INIT(vlc,0.7.1-cvs)
|
||||
|
||||
@ -3586,6 +3586,7 @@ AC_CONFIG_FILES([
|
||||
modules/demux/avi/Makefile
|
||||
modules/demux/mp4/Makefile
|
||||
modules/demux/mpeg/Makefile
|
||||
modules/demux/playlist/Makefile
|
||||
modules/demux/util/Makefile
|
||||
modules/gui/Makefile
|
||||
modules/gui/beos/Makefile
|
||||
@ -3606,6 +3607,7 @@ AC_CONFIG_FILES([
|
||||
modules/misc/memcpy/Makefile
|
||||
modules/misc/network/Makefile
|
||||
modules/misc/testsuite/Makefile
|
||||
modules/misc/playlist/Makefile
|
||||
modules/mux/Makefile
|
||||
modules/mux/mpeg/Makefile
|
||||
modules/packetizer/Makefile
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Collection of useful common types and macros definitions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998, 1999, 2000 VideoLAN
|
||||
* $Id: vlc_common.h,v 1.101 2004/01/09 18:32:03 gbazin Exp $
|
||||
* $Id: vlc_common.h,v 1.102 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@via.ecp.fr>
|
||||
* Vincent Seguin <seguin@via.ecp.fr>
|
||||
@ -192,6 +192,7 @@ typedef struct playlist_item_t playlist_item_t;
|
||||
typedef struct playlist_group_t playlist_group_t;
|
||||
typedef struct item_info_t item_info_t;
|
||||
typedef struct item_info_category_t item_info_category_t;
|
||||
typedef struct playlist_export_t playlist_export_t;
|
||||
|
||||
/* Modules */
|
||||
typedef struct module_bank_t module_bank_t;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* vlc_playlist.h : Playlist functions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2004 VideoLAN
|
||||
* $Id: vlc_playlist.h,v 1.23 2004/01/10 14:24:33 hartman Exp $
|
||||
* $Id: vlc_playlist.h,v 1.24 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@zoy.org>
|
||||
*
|
||||
@ -56,6 +56,15 @@ struct item_info_category_t
|
||||
item_info_t **pp_infos; /**< Pointer to an array of infos */
|
||||
};
|
||||
|
||||
/**
|
||||
* playlist export helper structure
|
||||
*/
|
||||
struct playlist_export_t
|
||||
{
|
||||
char *psz_filename;
|
||||
FILE *p_file;
|
||||
};
|
||||
|
||||
/**
|
||||
* playlist item
|
||||
* \see playlist_t
|
||||
@ -209,8 +218,8 @@ VLC_EXPORT( int, playlist_Sort, ( playlist_t *, int, int) );
|
||||
VLC_EXPORT( int, playlist_Move, ( playlist_t *, int, int ) );
|
||||
|
||||
/* Load/Save */
|
||||
VLC_EXPORT( int, playlist_LoadFile, ( playlist_t *, const char * ) );
|
||||
VLC_EXPORT( int, playlist_SaveFile, ( playlist_t *, const char * ) );
|
||||
VLC_EXPORT( int, playlist_Import, ( playlist_t *, const char * ) );
|
||||
VLC_EXPORT( int, playlist_Export, ( playlist_t *, const char *, const char * ) );
|
||||
|
||||
/**
|
||||
* tell if a playlist is currently playing.
|
||||
|
3
modules/demux/playlist/Modules.am
Normal file
3
modules/demux/playlist/Modules.am
Normal file
@ -0,0 +1,3 @@
|
||||
SOURCES_playlist = playlist.c \
|
||||
old.c \
|
||||
m3u.c
|
84
modules/demux/playlist/m3u.c
Normal file
84
modules/demux/playlist/m3u.c
Normal file
@ -0,0 +1,84 @@
|
||||
/*****************************************************************************
|
||||
* m3u.c : M3U playlist format import
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VideoLAN
|
||||
* $Id: m3u.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include <stdlib.h> /* malloc(), free() */
|
||||
|
||||
#include <vlc/vlc.h>
|
||||
#include <vlc/intf.h>
|
||||
|
||||
#include <errno.h> /* ENOMEM */
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
int Import_M3U ( vlc_object_t * );
|
||||
static int Demux( demux_t *p_demux);
|
||||
static int Control( demux_t *p_demux, int i_query, va_list args );
|
||||
|
||||
/*****************************************************************************
|
||||
* Import_Old : main import function
|
||||
*****************************************************************************/
|
||||
int Import_M3U( vlc_object_t *p_this )
|
||||
{
|
||||
demux_t *p_demux = (demux_t *)p_this;
|
||||
|
||||
uint8_t *p_peek;
|
||||
|
||||
if( stream_Peek( p_demux->s , &p_peek, 7 ) < 7 )
|
||||
{
|
||||
msg_Err( p_demux, "cannot peek" );
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
|
||||
if( strncmp( p_peek, "#EXTM3U", 7 ) )
|
||||
{
|
||||
msg_Warn(p_demux, "m3u import module discarded: invalid file");
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
msg_Info( p_demux, "Found valid M3U playlist file");
|
||||
|
||||
p_demux->pf_control = Control;
|
||||
p_demux->pf_demux = Demux;
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
static int Demux( demux_t *p_demux)
|
||||
{
|
||||
msg_Warn(p_demux, "Not yet implemented" );
|
||||
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_demux,
|
||||
VLC_OBJECT_PLAYLIST, FIND_PARENT );
|
||||
|
||||
p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
|
||||
vlc_object_release( p_playlist );
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
{
|
||||
return VLC_EGENERIC;
|
||||
}
|
114
modules/demux/playlist/old.c
Normal file
114
modules/demux/playlist/old.c
Normal file
@ -0,0 +1,114 @@
|
||||
/*****************************************************************************
|
||||
* old.c : Old playlist format import
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VideoLAN
|
||||
* $Id: old.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include <stdlib.h> /* malloc(), free() */
|
||||
|
||||
#include <vlc/vlc.h>
|
||||
#include <vlc/intf.h>
|
||||
|
||||
#include <errno.h> /* ENOMEM */
|
||||
|
||||
#define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5"
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
int Import_Old ( vlc_object_t * );
|
||||
static int Demux( demux_t *p_demux);
|
||||
static int Control( demux_t *p_demux, int i_query, va_list args );
|
||||
|
||||
/*****************************************************************************
|
||||
* Import_Old : main import function
|
||||
*****************************************************************************/
|
||||
int Import_Old( vlc_object_t *p_this )
|
||||
{
|
||||
demux_t *p_demux = (demux_t *)p_this;
|
||||
uint8_t *p_peek;
|
||||
|
||||
if( stream_Peek( p_demux->s, &p_peek, 31 ) < 31 )
|
||||
{
|
||||
msg_Err( p_demux, "cannot peek" );
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
|
||||
if( strncmp( p_peek, PLAYLIST_FILE_HEADER , 31 ) )
|
||||
{
|
||||
msg_Warn(p_demux, "old import module discarded: invalid file");
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
msg_Info( p_demux, "Found valid old playlist file");
|
||||
|
||||
p_demux->pf_control = Control;
|
||||
p_demux->pf_demux = Demux;
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
static int Demux( demux_t *p_demux)
|
||||
{
|
||||
char *psz_line;
|
||||
/* Attach playlist and start reading data */
|
||||
playlist_t *p_playlist;
|
||||
|
||||
p_playlist = (playlist_t*)vlc_object_find( p_demux,
|
||||
VLC_OBJECT_PLAYLIST, FIND_PARENT );
|
||||
if( !p_playlist )
|
||||
{
|
||||
msg_Err( p_demux, "cannot attach playlist" );
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
|
||||
p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
|
||||
while( ( psz_line = stream_ReadLine( p_demux->s) ) != NULL )
|
||||
{
|
||||
if( ( psz_line[0] == '#' ) || (psz_line[0] == '\r') ||
|
||||
( psz_line[0] == '\n') || (psz_line[0] == (char)0) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* Remove end of line */
|
||||
if( psz_line[strlen(psz_line) -1 ] == '\n' ||
|
||||
psz_line[strlen(psz_line) -1 ] == '\r' )
|
||||
{
|
||||
psz_line[ strlen(psz_line) -1 ] = (char)0;
|
||||
if( psz_line[strlen(psz_line) - 1 ] == '\r' )
|
||||
psz_line[strlen(psz_line) - 1 ] = (char)0;
|
||||
}
|
||||
playlist_Add( p_playlist, psz_line, psz_line, PLAYLIST_APPEND,
|
||||
PLAYLIST_END );
|
||||
|
||||
free( psz_line );
|
||||
}
|
||||
|
||||
p_demux->b_die = VLC_TRUE;
|
||||
vlc_object_release( p_playlist );
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
static int Control( demux_t *p_demux, int i_query, va_list args )
|
||||
{
|
||||
return VLC_EGENERIC;
|
||||
}
|
52
modules/demux/playlist/playlist.c
Normal file
52
modules/demux/playlist/playlist.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*****************************************************************************
|
||||
* playlist.c : Playlist import module
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VideoLAN
|
||||
* $Id: playlist.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include <vlc/vlc.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Prototypes
|
||||
***************************************************************************/
|
||||
int Import_Old ( vlc_object_t * );
|
||||
int Import_M3U ( vlc_object_t * );
|
||||
|
||||
/*****************************************************************************
|
||||
* Module descriptor
|
||||
*****************************************************************************/
|
||||
vlc_module_begin();
|
||||
|
||||
add_shortcut( "playlist" );
|
||||
|
||||
set_description( _("Old playlist open") );
|
||||
add_shortcut( "old-open" );
|
||||
set_capability( "demux2" , 10 );
|
||||
set_callbacks( Import_Old , NULL );
|
||||
|
||||
add_submodule();
|
||||
set_description( _("M3U playlist import") );
|
||||
add_shortcut( "m3u-open" );
|
||||
set_capability( "demux2" , 10 );
|
||||
set_callbacks( Import_M3U , NULL );
|
||||
vlc_module_end();
|
@ -2,7 +2,7 @@
|
||||
* playlist.cpp : wxWindows plugin for vlc
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2000-2004 VideoLAN
|
||||
* $Id: playlist.cpp,v 1.35 2004/01/10 03:36:03 hartman Exp $
|
||||
* $Id: playlist.cpp,v 1.36 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
|
||||
*
|
||||
@ -86,7 +86,9 @@ enum
|
||||
Search_Event,
|
||||
|
||||
/* controls */
|
||||
ListView_Event
|
||||
ListView_Event,
|
||||
|
||||
Browse_Event, /* For export playlist */
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(Playlist, wxFrame)
|
||||
@ -154,6 +156,14 @@ BEGIN_EVENT_TABLE(NewGroup, wxDialog)
|
||||
EVT_BUTTON( wxID_CANCEL, NewGroup::OnCancel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
/* Event Table for the ExportPlaylist class */
|
||||
BEGIN_EVENT_TABLE(ExportPlaylist, wxDialog)
|
||||
EVT_BUTTON( wxID_OK, ExportPlaylist::OnOk)
|
||||
EVT_BUTTON( wxID_CANCEL, ExportPlaylist::OnCancel)
|
||||
EVT_BUTTON( Browse_Event, ExportPlaylist::OnBrowse)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*****************************************************************************
|
||||
* Constructor.
|
||||
*****************************************************************************/
|
||||
@ -408,17 +418,18 @@ void Playlist::UpdateItem( int i )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( i < 0 || i > p_playlist->i_size )
|
||||
if( i < 0 || i >= p_playlist->i_size || !p_playlist->pp_items[i] )
|
||||
{
|
||||
vlc_object_release(p_playlist);
|
||||
return;
|
||||
}
|
||||
listview->SetItem( i, 0, wxL2U(p_playlist->pp_items[i]->psz_name) );
|
||||
listview->SetItem( i, 1, wxL2U( playlist_GetInfo( p_playlist, i,
|
||||
"General" , "Author" ) ) );
|
||||
_("General") , _("Author") ) ) );
|
||||
char *psz_group = playlist_FindGroup(p_playlist,p_playlist->
|
||||
pp_items[i]->i_group);
|
||||
listview->SetItem( i, 2,
|
||||
wxL2U(playlist_FindGroup(p_playlist,p_playlist->
|
||||
pp_items[i]->i_group) ) );
|
||||
wxL2U( psz_group ? psz_group : _("Normal") ) );
|
||||
|
||||
if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE )
|
||||
{
|
||||
@ -577,23 +588,9 @@ void Playlist::OnClose( wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
playlist_t *p_playlist =
|
||||
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
|
||||
FIND_ANYWHERE );
|
||||
if( p_playlist == NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
wxFileDialog dialog( this, wxU(_("Save playlist")),
|
||||
wxT(""), wxT(""), wxT("*"), wxSAVE );
|
||||
|
||||
if( dialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
playlist_SaveFile( p_playlist, dialog.GetPath().mb_str() );
|
||||
}
|
||||
|
||||
vlc_object_release( p_playlist );
|
||||
ExportPlaylist *exp_pl = new ExportPlaylist( p_intf, this);
|
||||
exp_pl->ShowModal();
|
||||
delete exp_pl;
|
||||
}
|
||||
|
||||
void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
|
||||
@ -611,7 +608,7 @@ void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
if( dialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
playlist_LoadFile( p_playlist, dialog.GetPath().mb_str() );
|
||||
playlist_Import( p_playlist, dialog.GetPath().mb_str() );
|
||||
}
|
||||
|
||||
vlc_object_release( p_playlist );
|
||||
@ -1153,7 +1150,7 @@ int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* NewGroup
|
||||
* NewGroup Class
|
||||
***************************************************************************/
|
||||
NewGroup::NewGroup( intf_thread_t *_p_intf, wxWindow *_p_parent ):
|
||||
wxDialog( _p_parent, -1, wxU(_("New Group")), wxDefaultPosition,
|
||||
@ -1218,9 +1215,9 @@ void NewGroup::OnOk( wxCommandEvent& event )
|
||||
{
|
||||
psz_name = NULL;
|
||||
}
|
||||
vlc_object_release( p_playlist );
|
||||
}
|
||||
|
||||
vlc_object_release( p_playlist );
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
@ -1228,3 +1225,138 @@ void NewGroup::OnCancel( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Export playlist class
|
||||
***************************************************************************/
|
||||
ExportPlaylist::ExportPlaylist( intf_thread_t *_p_intf, wxWindow *_p_parent ):
|
||||
wxDialog( _p_parent, -1, wxU(_("Export playlist")), wxDefaultPosition,
|
||||
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
|
||||
{
|
||||
vlc_list_t *p_list;
|
||||
module_t *p_module;
|
||||
|
||||
/* Initializations */
|
||||
p_intf = _p_intf;
|
||||
SetIcon( *p_intf->p_sys->p_icon );
|
||||
|
||||
/* Create a panel to put everything in*/
|
||||
wxPanel *panel = new wxPanel( this, -1 );
|
||||
panel->SetAutoLayout( TRUE );
|
||||
|
||||
/* Create the file box */
|
||||
wxStaticBox *file_box = new wxStaticBox( panel, -1,
|
||||
wxU(_("File to save to")) );
|
||||
wxStaticBoxSizer *file_sizer = new wxStaticBoxSizer( file_box,
|
||||
wxHORIZONTAL );
|
||||
|
||||
file_text = new wxTextCtrl(panel, -1, wxU(""),wxDefaultPosition,
|
||||
wxSize(250,-1),wxTE_PROCESS_ENTER);
|
||||
|
||||
file_text->SetToolTip( wxU(_("Enter the name of the file to export "
|
||||
"the playlist to.")) );
|
||||
|
||||
wxButton *file_button = new wxButton( panel, Browse_Event,
|
||||
wxU(_("Browse")) );
|
||||
|
||||
file_sizer->Add( file_text, 0, wxALL | wxALIGN_CENTER , 5 );
|
||||
file_sizer->Add( file_button, 0, wxALL | wxALIGN_CENTER , 5 );
|
||||
|
||||
/* Create the type box */
|
||||
wxStaticBox *type_box = new wxStaticBox( panel, -1,
|
||||
wxU(_("Select export type")) );
|
||||
|
||||
wxStaticBoxSizer *type_sizer = new wxStaticBoxSizer( type_box,
|
||||
wxHORIZONTAL );
|
||||
|
||||
type_combo = new wxComboBox( panel, -1, wxT(""), wxDefaultPosition,
|
||||
wxSize(250, -1), 0, NULL );
|
||||
|
||||
type_sizer->Add( type_combo, 0, wxALL | wxALIGN_CENTER, 5 );
|
||||
type_sizer->Layout();
|
||||
|
||||
|
||||
|
||||
wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) );
|
||||
ok_button->SetDefault();
|
||||
wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
|
||||
wxU(_("Cancel")) );
|
||||
|
||||
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
button_sizer->Add( ok_button, 0, wxALL, 5 );
|
||||
button_sizer->Add( cancel_button, 0, wxALL, 5 );
|
||||
button_sizer->Layout();
|
||||
|
||||
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
panel_sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
|
||||
panel_sizer->Add( type_sizer, 0, wxEXPAND | wxALL, 5 );
|
||||
panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 );
|
||||
panel_sizer->Layout();
|
||||
|
||||
panel->SetSizerAndFit( panel_sizer );
|
||||
|
||||
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
main_sizer->Add( panel, 1, wxEXPAND, 0 );
|
||||
main_sizer->Layout();
|
||||
SetSizerAndFit( main_sizer );
|
||||
|
||||
/* build a list of available modules */
|
||||
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
|
||||
for( int i_index = 0; i_index < p_list->i_count; i_index++ )
|
||||
{
|
||||
p_module = (module_t *)p_list->p_values[i_index].p_object ;
|
||||
if( !strcmp( p_module->psz_capability, "playlist export" ) )
|
||||
{
|
||||
type_combo->Append( wxU(p_module->psz_longname),
|
||||
p_module->pp_shortcuts[1] ?
|
||||
p_module->pp_shortcuts[1] :
|
||||
p_module->psz_object_name );
|
||||
}
|
||||
}
|
||||
vlc_list_release( p_list );
|
||||
}
|
||||
|
||||
|
||||
ExportPlaylist::~ExportPlaylist()
|
||||
{
|
||||
}
|
||||
|
||||
void ExportPlaylist::OnOk( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
playlist_t * p_playlist =
|
||||
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
|
||||
FIND_ANYWHERE );
|
||||
|
||||
if( p_playlist )
|
||||
{
|
||||
char *psz_type = (char *)type_combo->GetClientData(
|
||||
type_combo->GetSelection() );
|
||||
if( file_text->GetValue().mb_str() && psz_type )
|
||||
{
|
||||
playlist_Export( p_playlist, file_text->GetValue().mb_str(),
|
||||
psz_type );
|
||||
}
|
||||
}
|
||||
|
||||
vlc_object_release( p_playlist );
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
void ExportPlaylist::OnCancel( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
void ExportPlaylist::OnBrowse( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxFileDialog dialog( this, wxU(_("Save playlist")),
|
||||
wxT(""), wxT(""), wxT("*"), wxSAVE );
|
||||
|
||||
if( dialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
file_text->SetValue( dialog.GetPath() );
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* preferences.cpp : wxWindows plugin for vlc
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2000-2001 VideoLAN
|
||||
* $Id: preferences.cpp,v 1.44 2003/12/22 02:24:52 sam Exp $
|
||||
* $Id: preferences.cpp,v 1.45 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Gildas Bazin <gbazin@netcourrier.com>
|
||||
*
|
||||
@ -328,7 +328,7 @@ static char * GetCapabilityHelp( char *psz_capability, int i_type)
|
||||
if( !strcasecmp(psz_capability,"video filter") )
|
||||
return i_type == 1 ? VIDEO_FILTER_TITLE : VIDEO_FILTER_HELP;
|
||||
|
||||
return "";
|
||||
return " ";
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -2,7 +2,7 @@
|
||||
* wxwindows.h: private wxWindows interface description
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999, 2000 VideoLAN
|
||||
* $Id: wxwindows.h,v 1.83 2004/01/05 13:00:39 zorglub Exp $
|
||||
* $Id: wxwindows.h,v 1.84 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Gildas Bazin <gbazin@netcourrier.com>
|
||||
*
|
||||
@ -740,6 +740,7 @@ private:
|
||||
/* Playlist */
|
||||
class ItemInfoDialog;
|
||||
class NewGroup;
|
||||
class ExportPlaylist;
|
||||
class Playlist: public wxFrame
|
||||
{
|
||||
public:
|
||||
@ -841,6 +842,24 @@ protected:
|
||||
char *psz_name;
|
||||
};
|
||||
|
||||
class ExportPlaylist: public wxDialog
|
||||
{
|
||||
public:
|
||||
/* Constructor */
|
||||
ExportPlaylist(intf_thread_t *p_intf, wxWindow *p_parent );
|
||||
virtual ~ExportPlaylist();
|
||||
|
||||
private:
|
||||
/* Event handlers (these functions should _not_ be virtual) */
|
||||
void OnOk( wxCommandEvent& event );
|
||||
void OnCancel( wxCommandEvent& event );
|
||||
void OnBrowse( wxCommandEvent& event );
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
intf_thread_t *p_intf;
|
||||
wxTextCtrl *file_text;
|
||||
wxComboBox *type_combo;
|
||||
};
|
||||
|
||||
/* ItemInfo Dialog */
|
||||
class ItemInfoDialog: public wxDialog
|
||||
|
60
modules/misc/playlist/export.c
Normal file
60
modules/misc/playlist/export.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* export.c : Playlist export module
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VideoLAN
|
||||
* $Id: export.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include <vlc/vlc.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Prototypes
|
||||
***************************************************************************/
|
||||
void Export_Native ( intf_thread_t *p_intf );
|
||||
void Export_M3U ( intf_thread_t *p_intf );
|
||||
void Export_Old ( intf_thread_t *p_intf );
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Module descriptor
|
||||
*****************************************************************************/
|
||||
vlc_module_begin();
|
||||
|
||||
add_submodule();
|
||||
set_description( _("Native playlist exporter") );
|
||||
add_shortcut( "export-native" );
|
||||
set_capability( "playlist export" , 0 );
|
||||
set_callbacks( Export_Native , NULL );
|
||||
|
||||
add_submodule();
|
||||
set_description( _("M3U playlist exporter") );
|
||||
add_shortcut( "export-m3u" );
|
||||
set_capability( "playlist export" , 0);
|
||||
set_callbacks( Export_M3U , NULL );
|
||||
|
||||
add_submodule();
|
||||
set_description( _("Old playlist exporter") );
|
||||
add_shortcut( "export-old" );
|
||||
set_capability( "playlist export" , 0);
|
||||
set_callbacks( Export_Old , NULL );
|
||||
|
||||
vlc_module_end();
|
69
modules/misc/playlist/m3u.c
Normal file
69
modules/misc/playlist/m3u.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
* m3u.c : M3U playlist export module
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VideoLAN
|
||||
* $Id: m3u.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include <stdlib.h> /* malloc(), free() */
|
||||
|
||||
#include <vlc/vlc.h>
|
||||
#include <vlc/intf.h>
|
||||
|
||||
#include <errno.h> /* ENOMEM */
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
int Export_M3U ( vlc_object_t * );
|
||||
|
||||
/*****************************************************************************
|
||||
* Export_M3U: main export function
|
||||
*****************************************************************************/
|
||||
int Export_M3U( vlc_object_t *p_this )
|
||||
{
|
||||
playlist_t *p_playlist = (playlist_t*)p_this;
|
||||
playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
|
||||
int i;
|
||||
|
||||
msg_Dbg(p_playlist, "Saving using M3U format");
|
||||
|
||||
/* Write header */
|
||||
fprintf( p_export->p_file, "#EXTM3U\n" );
|
||||
|
||||
/* Go through the playlist and add items */
|
||||
for( i = 0; i< p_playlist->i_size ; i++)
|
||||
{
|
||||
if( strcmp( p_playlist->pp_items[i]->psz_name,
|
||||
p_playlist->pp_items[i]->psz_uri ) )
|
||||
{
|
||||
char *psz_author = playlist_GetInfo( p_playlist, i, _("General"),
|
||||
_("Author") );
|
||||
fprintf( p_export->p_file,"#EXTINF:%i,%s%s\n",
|
||||
(int)(p_playlist->pp_items[i]->i_duration/1000000),
|
||||
psz_author ? psz_author : "",
|
||||
p_playlist->pp_items[i]->psz_name );
|
||||
}
|
||||
fprintf( p_export->p_file, "%s\n", p_playlist->pp_items[i]->psz_uri );
|
||||
}
|
||||
return VLC_SUCCESS;
|
||||
}
|
48
modules/misc/playlist/native.c
Normal file
48
modules/misc/playlist/native.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*****************************************************************************
|
||||
* native.c : Native playlist export module
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VideoLAN
|
||||
* $Id: native.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include <stdlib.h> /* malloc(), free() */
|
||||
|
||||
#include <vlc/vlc.h>
|
||||
#include <vlc/intf.h>
|
||||
|
||||
#include <errno.h> /* ENOMEM */
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
int Export_Native ( vlc_object_t * );
|
||||
|
||||
/*****************************************************************************
|
||||
* Native: main export function
|
||||
*****************************************************************************/
|
||||
int Export_Native( vlc_object_t *p_this )
|
||||
{
|
||||
playlist_t *p_playlist = (playlist_t*)p_this;
|
||||
playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
|
||||
|
||||
msg_Dbg(p_playlist, "Saving using native format");
|
||||
}
|
60
modules/misc/playlist/old.c
Normal file
60
modules/misc/playlist/old.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* old.c : Old playlist format import/export
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2004 VideoLAN
|
||||
* $Id: old.c,v 1.1 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#include <stdlib.h> /* malloc(), free() */
|
||||
|
||||
#include <vlc/vlc.h>
|
||||
#include <vlc/intf.h>
|
||||
|
||||
#include <errno.h> /* ENOMEM */
|
||||
|
||||
#define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5"
|
||||
|
||||
/*****************************************************************************
|
||||
* Local prototypes
|
||||
*****************************************************************************/
|
||||
int Export_Old ( vlc_object_t * );
|
||||
|
||||
/*****************************************************************************
|
||||
* Export_Old : main export function
|
||||
*****************************************************************************/
|
||||
int Export_Old( vlc_object_t *p_this )
|
||||
{
|
||||
playlist_t *p_playlist = (playlist_t*)p_this;
|
||||
playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
|
||||
int i;
|
||||
|
||||
msg_Dbg(p_playlist, "Saving using old format");
|
||||
|
||||
/* Write header */
|
||||
fprintf( p_export->p_file , PLAYLIST_FILE_HEADER "\n" );
|
||||
|
||||
for ( i = 0 ; i < p_playlist->i_size ; i++ )
|
||||
{
|
||||
fprintf( p_export->p_file , "%s\n" , p_playlist->pp_items[i]->psz_uri );
|
||||
}
|
||||
return VLC_SUCCESS;
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
* playlist.c : Playlist groups management functions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2004 VideoLAN
|
||||
* $Id: group.c,v 1.6 2004/01/06 08:50:20 zorglub Exp $
|
||||
* $Id: group.c,v 1.7 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Clément Stenac <zorglub@videolan.org>
|
||||
*
|
||||
@ -119,7 +119,7 @@ int playlist_DeleteGroup( playlist_t *p_playlist, int i_id )
|
||||
char *playlist_FindGroup( playlist_t *p_playlist, int i_id )
|
||||
{
|
||||
int i;
|
||||
for( i=0 ; i<= p_playlist->i_groups; i++ )
|
||||
for( i=0 ; i< p_playlist->i_groups; i++ )
|
||||
{
|
||||
if( p_playlist->pp_groups[i]->i_id == i_id )
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
* item-ext.c : Exported playlist item functions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2004 VideoLAN
|
||||
* $Id: item-ext.c,v 1.7 2004/01/10 14:24:33 hartman Exp $
|
||||
* $Id: item-ext.c,v 1.8 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@zoy.org>
|
||||
* Clément Stenac <zorglub@videolan.org>
|
||||
@ -387,6 +387,14 @@ int playlist_Clear( playlist_t * p_playlist ) {
|
||||
{
|
||||
playlist_Delete( p_playlist, 0 );
|
||||
}
|
||||
|
||||
p_playlist->i_index = -1;
|
||||
p_playlist->i_size = 0;
|
||||
p_playlist->pp_items = NULL;
|
||||
|
||||
p_playlist->i_groups = 0;
|
||||
p_playlist->pp_groups = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* loadsave.c : Playlist loading / saving functions
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1999-2004 VideoLAN
|
||||
* $Id: loadsave.c,v 1.3 2004/01/06 08:50:20 zorglub Exp $
|
||||
* $Id: loadsave.c,v 1.4 2004/01/11 00:45:06 zorglub Exp $
|
||||
*
|
||||
* Authors: Samuel Hocevar <sam@zoy.org>
|
||||
*
|
||||
@ -33,160 +33,89 @@
|
||||
|
||||
#include "vlc_playlist.h"
|
||||
|
||||
#define PLAYLIST_FILE_HEADER_0_5 "# vlc playlist file version 0.5"
|
||||
#define PLAYLIST_FILE_HEADER_0_6 "# vlc playlist file version 0.6"
|
||||
#define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* playlist_LoadFile: load a playlist file.
|
||||
* playlist_Import: load a playlist file.
|
||||
****************************************************************************/
|
||||
int playlist_LoadFile( playlist_t * p_playlist, const char *psz_filename )
|
||||
int playlist_Import( playlist_t * p_playlist, const char *psz_filename )
|
||||
{
|
||||
FILE *file;
|
||||
char line[1024];
|
||||
int i_current_status;
|
||||
int i_format;
|
||||
int i;
|
||||
playlist_item_t *p_item;
|
||||
char *psz_uri;
|
||||
int i_id;
|
||||
|
||||
msg_Dbg( p_playlist, "opening playlist file %s", psz_filename );
|
||||
msg_Dbg( p_playlist, "clearing playlist");
|
||||
|
||||
file = fopen( psz_filename, "rt" );
|
||||
if( !file )
|
||||
/* Create our "fake" playlist item */
|
||||
playlist_Clear( p_playlist );
|
||||
|
||||
|
||||
psz_uri = (char *)malloc(sizeof(char)*strlen(psz_filename) + 17 );
|
||||
sprintf( psz_uri, "file/playlist://%s", psz_filename);
|
||||
|
||||
i_id = playlist_Add( p_playlist, psz_uri, psz_uri,
|
||||
PLAYLIST_INSERT | PLAYLIST_GO , PLAYLIST_END);
|
||||
|
||||
p_item = playlist_GetItemById( p_playlist, i_id );
|
||||
p_item->b_autodeletion = VLC_TRUE;
|
||||
|
||||
//p_playlist->i_index = 0;
|
||||
|
||||
/*
|
||||
* if( p_item )
|
||||
{
|
||||
msg_Err( p_playlist, "playlist file %s does not exist", psz_filename );
|
||||
return -1;
|
||||
p_playlist->p_input = input_CreateThread( p_playlist, p_item );
|
||||
}
|
||||
fseek( file, 0L, SEEK_SET );
|
||||
*/
|
||||
|
||||
/* check the file is not empty */
|
||||
if ( ! fgets( line, 1024, file ) )
|
||||
{
|
||||
msg_Err( p_playlist, "playlist file %s is empty", psz_filename );
|
||||
fclose( file );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* get rid of line feed */
|
||||
if( line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r' )
|
||||
{
|
||||
line[strlen(line)-1] = (char)0;
|
||||
if( line[strlen(line)-1] == '\r' ) line[strlen(line)-1] = (char)0;
|
||||
}
|
||||
/* check the file format is valid */
|
||||
if ( !strcmp ( line , PLAYLIST_FILE_HEADER_0_5 ) )
|
||||
{
|
||||
i_format = 5;
|
||||
}
|
||||
else if( !strcmp ( line , PLAYLIST_FILE_HEADER_0_6 ) )
|
||||
{
|
||||
i_format = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_Err( p_playlist, "playlist file %s format is unsupported"
|
||||
, psz_filename );
|
||||
fclose( file );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* stop playing */
|
||||
i_current_status = p_playlist->i_status;
|
||||
if ( p_playlist->i_status != PLAYLIST_STOPPED )
|
||||
{
|
||||
playlist_Stop ( p_playlist );
|
||||
}
|
||||
|
||||
/* delete current content of the playlist */
|
||||
for( i = p_playlist->i_size - 1; i >= 0; i-- )
|
||||
{
|
||||
playlist_Delete ( p_playlist , i );
|
||||
}
|
||||
|
||||
/* simply add each line */
|
||||
while( fgets( line, 1024, file ) )
|
||||
{
|
||||
/* ignore comments or empty lines */
|
||||
if( (line[0] == '#') || (line[0] == '\r') || (line[0] == '\n')
|
||||
|| (line[0] == (char)0) )
|
||||
continue;
|
||||
|
||||
/* get rid of line feed */
|
||||
if( line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r' )
|
||||
{
|
||||
line[strlen(line)-1] = (char)0;
|
||||
if( line[strlen(line)-1] == '\r' ) line[strlen(line)-1] = (char)0;
|
||||
}
|
||||
if( i_format == 5 )
|
||||
{
|
||||
playlist_Add ( p_playlist , (char *)&line , (char *)&line,
|
||||
PLAYLIST_APPEND , PLAYLIST_END );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_Warn( p_playlist, "Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
/* start playing */
|
||||
if ( i_current_status != PLAYLIST_STOPPED )
|
||||
{
|
||||
playlist_Play ( p_playlist );
|
||||
}
|
||||
|
||||
fclose( file );
|
||||
|
||||
return 0;
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* playlist_SaveFile: Save a playlist in a file.
|
||||
*****************************************************************************/
|
||||
int playlist_SaveFile( playlist_t * p_playlist, const char * psz_filename )
|
||||
int playlist_Export( playlist_t * p_playlist, const char *psz_filename ,
|
||||
const char *psz_type)
|
||||
{
|
||||
FILE *file;
|
||||
int i;
|
||||
extern int errno;
|
||||
module_t *p_module;
|
||||
playlist_export_t *p_export;
|
||||
|
||||
vlc_mutex_lock( &p_playlist->object_lock );
|
||||
msg_Info( p_playlist, "Saving playlist to file %s", psz_filename );
|
||||
|
||||
msg_Dbg( p_playlist, "saving playlist file %s", psz_filename );
|
||||
|
||||
file = fopen( psz_filename, "wt" );
|
||||
if( !file )
|
||||
/* Prepare the playlist_export_t structure */
|
||||
p_export = (playlist_export_t *)malloc( sizeof(playlist_export_t) );
|
||||
if( !p_export)
|
||||
{
|
||||
msg_Err( p_playlist , "could not create playlist file %s"
|
||||
, psz_filename );
|
||||
msg_Err( p_playlist, "Out of memory");
|
||||
return VLC_ENOMEM;
|
||||
}
|
||||
p_export->p_file = fopen( psz_filename, "wt" );
|
||||
if( !p_export->p_file )
|
||||
{
|
||||
msg_Err( p_playlist , "Could not create playlist file %s (%s)"
|
||||
, psz_filename, strerror(errno) );
|
||||
return -1;
|
||||
}
|
||||
/* Save is done in 0_5 mode at the moment*/
|
||||
|
||||
fprintf( file , PLAYLIST_FILE_HEADER_0_5 "\n" );
|
||||
p_playlist->p_private = (void *)p_export;
|
||||
/* Lock the playlist */
|
||||
vlc_mutex_lock( &p_playlist->object_lock );
|
||||
|
||||
for ( i = 0 ; i < p_playlist->i_size ; i++ )
|
||||
/* And call the module ! All work is done now */
|
||||
p_module = module_Need( p_playlist, "playlist export", psz_type);
|
||||
if( !p_module )
|
||||
{
|
||||
fprintf( file , p_playlist->pp_items[i]->psz_uri );
|
||||
fprintf( file , "\n" );
|
||||
msg_Warn( p_playlist, "Failed to export playlist" );
|
||||
vlc_mutex_unlock( &p_playlist->object_lock );
|
||||
return VLC_ENOOBJ;
|
||||
}
|
||||
#if 0
|
||||
fprintf( file, PLAYLIST_FILE_HEADER_0_6 "\n" );
|
||||
module_Unneed( p_playlist , p_module );
|
||||
|
||||
for ( i=0 ; i< p_playlist->i_size ; i++ )
|
||||
{
|
||||
fprintf( file, p_playlist->pp_items[i]->psz_uri );
|
||||
fprintf( file, "||" );
|
||||
fprintf( file, p_playlist->pp_items[i]->psz_name );
|
||||
fprintf( file, "||" );
|
||||
fprintf( file, "%i",p_playlist->pp_items[i]->b_enabled = VLC_TRUE ?
|
||||
1:0 );
|
||||
fprintf( file, "||" );
|
||||
fprintf( file, "%i", p_playlist->pp_items[i]->i_group );
|
||||
fprintf( file, "||" );
|
||||
fprintf( file, p_playlist->pp_items[i]->psz_author );
|
||||
fprintf( file , "\n" );
|
||||
}
|
||||
#endif
|
||||
fclose( file );
|
||||
fclose( p_export->p_file );
|
||||
|
||||
vlc_mutex_unlock( &p_playlist->object_lock );
|
||||
|
||||
return 0;
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user