cmd_playlist.cpp 3.29 KB
Newer Older
1 2 3
/*****************************************************************************
 * cmd_playlist.cpp
 *****************************************************************************
4
 * Copyright (C) 2003 the VideoLAN team
5
 * $Id$
6 7
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8
 *          Olivier Teulière <ipkiss@via.ecp.fr>
9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * 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
Antoine Cellerier's avatar
Antoine Cellerier committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 24 25
 *****************************************************************************/

#include "cmd_playlist.hpp"
Clément Stenac's avatar
Clément Stenac committed
26
#include <vlc_playlist.h>
27 28
#include "../src/vlcproc.hpp"
#include "../utils/var_bool.hpp"
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

void CmdPlaylistDel::execute()
{
    m_rList.delSelected();
}

void CmdPlaylistNext::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist != NULL )
    {
        playlist_Next( pPlaylist );
    }
}


void CmdPlaylistPrevious::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist != NULL )
    {
        playlist_Prev( pPlaylist );
    }
}
53 54 55 56 57 58 59 60 61 62 63 64 65


void CmdPlaylistRandom::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist != NULL )
    {
        vlc_value_t val;
        val.b_bool = m_value;
        var_Set( pPlaylist , "random", val);
    }
}

66 67 68 69 70 71 72 73 74 75 76 77

void CmdPlaylistLoop::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist != NULL )
    {
        vlc_value_t val;
        val.b_bool = m_value;
        var_Set( pPlaylist , "loop", val);
    }
}

78 79 80 81 82 83 84 85 86 87 88 89

void CmdPlaylistRepeat::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist != NULL )
    {
        vlc_value_t val;
        val.b_bool = m_value;
        var_Set( pPlaylist , "repeat", val);
    }
}

90 91 92 93 94

void CmdPlaylistLoad::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist != NULL )
95
        playlist_Import( pPlaylist, m_file.c_str() );
96 97 98 99 100 101 102 103
}


void CmdPlaylistSave::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist != NULL )
    {
104
        static const char psz_xspf[] = "export-xspf",
105 106
                          psz_m3u[] = "export-m3u",
                          psz_html[] = "export-html";
107 108 109
        const char *psz_module;
        if( m_file.find( ".xsp", 0 ) != string::npos )
            psz_module = psz_xspf;
110 111 112 113
        else if( m_file.find( "m3u", 0 ) != string::npos )
            psz_module = psz_m3u;
        else if( m_file.find( "html", 0 ) != string::npos )
            psz_module = psz_html;
114 115
        else
        {
116 117
            msg_Err( getIntf(), "Impossible to recognise the file type" );
            return;
118
        }
119

120
        playlist_Export( pPlaylist, m_file.c_str(), pPlaylist->p_local_category, psz_module );
121 122
    }
}