1 /*****************************************************************************
2 * Copyright (C) 2019 VLC authors and VideoLAN
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * ( at your option ) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17 *****************************************************************************/
18 #include "playlist_item.hpp"
21 //namespace playlist {
23 PlaylistItem::PlaylistItem(vlc_playlist_item_t
* item
)
33 bool PlaylistItem::isSelected() const
38 void PlaylistItem::setSelected(bool selected
)
40 d
->selected
= selected
;
43 QString
PlaylistItem::getTitle() const
48 QString
PlaylistItem::getArtist() const
53 QString
PlaylistItem::getAlbum() const
58 QUrl
PlaylistItem::getArtwork() const
63 vlc_tick_t
PlaylistItem::getDuration() const
68 QUrl
PlaylistItem::getUrl() const
73 void PlaylistItem::sync() {
74 input_item_t
*media
= vlc_playlist_item_GetMedia(d
->item
.get());
75 vlc_mutex_lock(&media
->lock
);
76 d
->duration
= media
->i_duration
;
77 d
->url
= media
->psz_uri
;
80 d
->title
= vlc_meta_Get(media
->p_meta
, vlc_meta_Title
);
81 d
->artist
= vlc_meta_Get(media
->p_meta
, vlc_meta_Artist
);
82 d
->album
= vlc_meta_Get(media
->p_meta
, vlc_meta_Album
);
83 d
->artwork
= vlc_meta_Get(media
->p_meta
, vlc_meta_ArtworkURL
);
86 if (d
->title
.isNull())
87 /* If there is no title, use the item name */
88 d
->title
= media
->psz_name
;
90 vlc_mutex_unlock(&media
->lock
);
93 PlaylistItem::operator bool() const
95 return d
&& d
->item
.get();