00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <vlc/vlc.h>
00028 #include <vlc/input.h>
00029 #include <vlc_playlist.h>
00030
00031 #include "playlist.h"
00032
00033
00034
00035
00036 #define AUTOSTART_TEXT N_( "Auto start" )
00037 #define AUTOSTART_LONGTEXT N_( "Automatically start the playlist when " \
00038 "it's loaded.\n" )
00039
00040 vlc_module_begin();
00041 add_shortcut( "playlist" );
00042 set_category( CAT_INPUT );
00043 set_subcategory( SUBCAT_INPUT_DEMUX );
00044
00045 add_bool( "playlist-autostart", 1, NULL, AUTOSTART_TEXT, AUTOSTART_LONGTEXT,
00046 VLC_FALSE );
00047
00048 set_shortname( _("Playlist") );
00049 set_description( _("Playlist") );
00050 add_shortcut( "old-open" );
00051 set_capability( "demux2", 10 );
00052 set_callbacks( E_(Import_Old), NULL );
00053 #if 0
00054 add_submodule();
00055 set_description( _("Native playlist import") );
00056 add_shortcut( "playlist" );
00057 add_shortcut( "native-open" );
00058 set_capability( "demux2", 10 );
00059 set_callbacks( E_(Import_Native), E_(Close_Native) );
00060 #endif
00061 add_submodule();
00062 set_description( _("M3U playlist import") );
00063 add_shortcut( "m3u-open" );
00064 set_capability( "demux2", 10 );
00065 set_callbacks( E_(Import_M3U), E_(Close_M3U) );
00066 add_submodule();
00067 set_description( _("PLS playlist import") );
00068 add_shortcut( "pls-open" );
00069 set_capability( "demux2", 10 );
00070 set_callbacks( E_(Import_PLS), E_(Close_PLS) );
00071 add_submodule();
00072 set_description( _("B4S playlist import") );
00073 add_shortcut( "b4s-open" );
00074 add_shortcut( "shout-b4s" );
00075 set_capability( "demux2", 10 );
00076 set_callbacks( E_(Import_B4S), E_(Close_B4S) );
00077 add_submodule();
00078 set_description( _("DVB playlist import") );
00079 add_shortcut( "dvb-open" );
00080 set_capability( "demux2", 10 );
00081 set_callbacks( E_(Import_DVB), E_(Close_DVB) );
00082 vlc_module_end();
00083
00084
00089 char *E_(FindPrefix)( demux_t *p_demux )
00090 {
00091 char *psz_name;
00092 char *psz_path = strdup( p_demux->psz_path );
00093
00094 #ifndef WIN32
00095 psz_name = strrchr( psz_path, '/' );
00096 #else
00097 psz_name = strrchr( psz_path, '\\' );
00098 if( !psz_name ) psz_name = strrchr( psz_path, '/' );
00099 #endif
00100 if( psz_name ) psz_name[1] = '\0';
00101 else *psz_path = '\0';
00102
00103 return psz_path;
00104 }
00105
00110 char *E_(ProcessMRL)( char *psz_mrl, char *psz_prefix )
00111 {
00112
00113
00114
00115
00116
00117
00118
00119 if( !psz_mrl || !*psz_mrl ) return NULL;
00120 if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
00121
00122
00123 if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
00124
00125
00126
00127 if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
00128
00129
00130 asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );
00131 return psz_mrl;
00132 }
00133
00134 vlc_bool_t E_(FindItem)( demux_t *p_demux, playlist_t *p_playlist,
00135 playlist_item_t **pp_item )
00136 {
00137 vlc_bool_t b_play = var_CreateGetBool( p_demux, "playlist-autostart" );
00138
00139 if( b_play && p_playlist->status.p_item &&
00140 &p_playlist->status.p_item->input ==
00141 ((input_thread_t *)p_demux->p_parent)->input.p_item )
00142 {
00143 msg_Dbg( p_playlist, "starting playlist playback" );
00144 *pp_item = p_playlist->status.p_item;
00145 b_play = VLC_TRUE;
00146 }
00147 else
00148 {
00149 input_item_t *p_current = ( (input_thread_t*)p_demux->p_parent)->
00150 input.p_item;
00151 *pp_item = playlist_LockItemGetByInput( p_playlist, p_current );
00152 if( !*pp_item )
00153 {
00154 msg_Dbg( p_playlist, "unable to find item in playlist");
00155 }
00156 msg_Dbg( p_playlist, "not starting playlist playback");
00157 b_play = VLC_FALSE;
00158 }
00159 return b_play;
00160 }