Debian Codegraph @

xbmc/music/MusicUtils.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include "media/MediaType.h"
12 #include "utils/ContentUtils.h"
13
14 #include <memory>
15 #include <string>
16 #include <vector>
17
18 class CFileItem;
19 class CFileItemList;
20
21 namespace MUSIC_UTILS
22 {
23 /*! \brief Show a dialog to allow the selection of type of art from a list.
24 Input is a fileitem list, with each item having an "arttype" property
25 e.g. "thumb", current art URL (if art exists), and label. One of these art types
26 can be selected, or a new art type added. The new art type is added as a new item
27 in the list, as well as returned as the selected art type.
28 \param artitems [in/out] a fileitem list to display
29 \return the selected art type e.g. "fanart" or empty string when cancelled.
30 \sa FillArtTypesList
31 */
32 std::string ShowSelectArtTypeDialog(CFileItemList& artitems);
33
34 /*! \brief Helper function to build a list of art types for a music library item.
35 This fetches the possible types of art for a song, album or artist, and the
36 current art URL (if the item has art of that type), for display on a dialog.
37 \param musicitem a music CFileItem (song, album or artist)
38 \param artitems [out] a fileitem list, each item having "arttype" property
39 e.g. "thumb", current art URL (if art exists), and localized label (for common arttypes)
40 \return true if art types are retrieved, false if none is found.
41 \sa ShowSelectArtTypeDialog
42 */
43 bool FillArtTypesList(CFileItem& musicitem, CFileItemList& artlist);
44
45 /*! \brief Helper function to asynchronously update art in the music database
46 and then refresh the album & artist art of the currently playing song.
47 For the song, album or artist this adds a job to the queue to update the art table
48 modifying, adding or deleting that type of art. Changes to album or artist art are
49 then passed to the currently playing song (if there is one).
50 \param item a shared pointer to a music CFileItem (song, album or artist)
51 \param strType the type of art e.g. "fanart" or "thumb" etc.
52 \param strArt art URL, when empty the entry for that type of art is deleted.
53 */
54 void UpdateArtJob(const std::shared_ptr<CFileItem>& pItem,
55 const std::string& strType,
56 const std::string& strArt);
57
58 /*! \brief Show a dialog to allow the selection of user rating.
59 \param iSelected the rating to show initially
60 \return the selected rating, 0 (no rating), 1 to 10 or -1 no rating selected
61 */
62 int ShowSelectRatingDialog(int iSelected);
63
64 /*! \brief Helper function to asynchronously update the user rating of a song
65 \param pItem pointer to song item being rated
66 \param userrating the userrating 0 = no rating, 1 to 10
67 */
68 void UpdateSongRatingJob(const std::shared_ptr<CFileItem>& pItem, int userrating);
69
70 /*! \brief Get the types of art for an artist or album that are to be
71 automatically fetched from local files during scanning
72 \param mediaType [in] artist or album
73 \return vector of art types that are to be fetched during scanning
74 */
75 std::vector<std::string> GetArtTypesToScan(const MediaType& mediaType);
76
77 /*! \brief Validate string is acceptable as the name of an additional art type
78 - limited length, and ascii alphanumberic characters only
79 \param potentialArtType [in] potential art type name
80 \return true if the art type is valid
81 */
82 bool IsValidArtType(const std::string& potentialArtType);
83
84 /*! \brief Check whether auto play next item is set for the given item.
85 \param item [in] the item to check
86 \return True if auto play next item is active, false otherwise.
87 */
88 bool IsAutoPlayNextItem(const CFileItem& item);
89
90 /*! \brief Start playback of the given item. If the item is a folder, build a playlist with
91 all items contained in the folder and start playback of the playlist. If item is a single music
92 item, start playback directly, without adding it to the music playlist first.
93 \param item [in] the item to play
94 \param player [in] the player to use, empty for default player
95 \param mode [in] queue all successors and play them after item
96 */
97 void PlayItem(const std::shared_ptr<CFileItem>& item,
98 const std::string& player,
99 ContentUtils::PlayMode mode = ContentUtils::PlayMode::CHECK_AUTO_PLAY_NEXT_ITEM);
100
101 enum class QueuePosition
102 {
103 POSITION_BEGIN, // place at begin of queue, before other items
104 POSITION_END, // place at end of queue, after other items
105 };
106
107 /*! \brief Queue the given item in the currently active playlist. If none is active, put the
108 item into the music playlist. Start playback of the playlist, if player is not already playing.
109 \param item [in] the item to queue
110 \param pos [in] whether to place the item and the begin or the end of the queue
111 */
112 void QueueItem(const std::shared_ptr<CFileItem>& item, QueuePosition pos);
113
114 /*! \brief For a given item, get the items to put in a playlist. If the item is a folder, all
115 subitems will be added recursively to the returned item list. If the item is a playlist, the
116 playlist will be loaded and contained items will be added to the returned item list. Shows a
117 busy dialog if action takes certain amount of time to give the user visual feedback.
118 \param item [in] the item to add to the playlist
119 \param queuedItems [out] the items that can be put in a play list
120 \return true on success, false otherwise
121 */
122 bool GetItemsForPlayList(const std::shared_ptr<CFileItem>& item, CFileItemList& queuedItems);
123
124 /*!
125 \brief Check whether the given item can be played by the app playlist player as one or more songs.
126 \param item The item to check
127 \return True if playable, false otherwise.
128 */
129 bool IsItemPlayable(const CFileItem& item);
130
131 } // namespace MUSIC_UTILS