MediaListPlayer.hpp 4.8 KB
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1 2 3 4 5 6
/*****************************************************************************
 * libvlc_MediaListPlayer.hpp: MediaListPlayer API
 *****************************************************************************
 * Copyright © 2014 the VideoLAN team
 *
 * Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
7
 *          Hugo Beauzée-Luyssen <hugo@beauzee.fr>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef LIBVLC_CXX_MEDIALISTPLAYER_H
#define LIBVLC_CXX_MEDIALISTPLAYER_H

27 28
#include <string>

29
#include "common.hpp"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
30
#include "Internal.hpp"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
31

32
namespace VLC
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
33 34
{

35
class EventManager;
36 37
class MediaPlayer;
class MediaList;
38

39
class VLCPP_API MediaListPlayer : public Internal<libvlc_media_list_player_t>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
40 41 42 43 44 45 46 47 48 49 50 51 52
{
public:
    /**
     * Copy libvlc_media_list_player_t from another to new MediaListPlayer object.
     * \param another existing MediaListPlayer
     */
    MediaListPlayer(const MediaListPlayer& another);

    /**
     * Copy libvlc_media_list_player_t from another MediaListPlayer
     * to this MediaListPlayer
     * \param another existing MediaListPlayer
     */
53
    MediaListPlayer& operator=(const MediaListPlayer& another);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

    /**
     * Check if 2 MediaListPlayer objects contain the same libvlc_media_list_player_t.
     * \param another another MediaListPlayer
     * \return true if they contain the same libvlc_media_list_player_t
     */
    bool operator==(const MediaListPlayer& another) const;

    ~MediaListPlayer();

    // libvlc_media_list_player_new
    /**
     * Create new media_list_player.
     *
     * \param p_instance  libvlc instance
     */
70
    MediaListPlayer(Instance & instance);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
71 72 73 74 75 76

    /**
     * Return the event manager of this media_list_player.
     *
     * \return the event manager
     */
77
    EventManager& eventManager();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
78 79 80 81 82 83 84 85 86 87 88 89 90

    /**
     * Replace media player in media_list_player with this instance.
     *
     * \param p_mi  media player instance
     */
    void setMediaPlayer(MediaPlayer & p_mi);

    /**
     * Set the media list associated with the player
     *
     * \param p_mlist  list of media
     */
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
91
    void setMediaList(MediaList & mlist);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161

    /**
     * Play media list
     */
    void play();

    /**
     * Toggle pause (or resume) media list
     */
    void pause();

    /**
     * Is media list playing?
     *
     * \return true for playing and false for not playing
     */
    bool isPlaying();

    /**
     * Get current libvlc_state of media list player
     *
     * \return libvlc_state_t for media list player
     */
    libvlc_state_t state();

    /**
     * Play media list item at position index
     *
     * \param i_index  index in media list to play
     *
     * \return 0 upon success -1 if the item wasn't found
     */
    int playItemAtIndex(int i_index);

    /**
     * Play the given media item
     *
     * \param p_md  the media instance
     *
     * \return 0 upon success, -1 if the media is not part of the media list
     */
    int playItem(Media & p_md);

    /**
     * Stop playing media list
     */
    void stop();

    /**
     * Play next item from media list
     *
     * \return 0 upon success -1 if there is no next item
     */
    int next();

    /**
     * Play previous item from media list
     *
     * \return 0 upon success -1 if there is no previous item
     */
    int previous();

    /**
     * Sets the playback mode for the playlist
     *
     * \param e_mode  playback mode specification
     */
    void setPlaybackMode(libvlc_playback_mode_t e_mode);

private:
162
    explicit MediaListPlayer(InternalPtr ptr);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176
    /**
     * Release a media_list_player after use Decrement the reference count of
     * a media player object. If the reference count is 0, then
     * MediaListPlayer::release() will release the media player object. If
     * the media player object has been released, then it should not be used
     * again.
     */
    void release();

    /**
     * Retain a reference to a media player list object. Use
     * MediaListPlayer::release() to decrement reference count.
     */
    void retain();
177 178 179 180

private:
    EventManager* m_eventManager;

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
181 182 183 184 185 186
};

} // namespace VLC

#endif