[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / video / VideoUtils.h
blobaebb637d9dbe3031e9e3fc202bcd6dede452b2b5
1 /*
2 * Copyright (C) 2022 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "utils/ContentUtils.h"
13 #include <memory>
15 class CFileItem;
16 class CFileItemList;
18 namespace VIDEO_UTILS
20 /*! \brief Check whether auto play next item is set for the media type of the given item.
21 \param item [in] the item to check
22 \return True if auto play next item is active, false otherwise.
24 bool IsAutoPlayNextItem(const CFileItem& item);
26 /*! \brief Check whether auto play next item is set for the given content type.
27 \param item [in] the content to check
28 \return True if auto play next item is active, false otherwise.
30 bool IsAutoPlayNextItem(const std::string& content);
32 /*! \brief Start playback of the given item. If the item is a folder, build a playlist with
33 all items contained in the folder and start playback of the playlist. If item is a single video
34 item, start playback directly, without adding it to the video playlist first.
35 \param item [in] the item to play
36 \param player [in] the player to use, empty for default player
37 \param mode [in] queue all successors and play them after item
39 void PlayItem(const std::shared_ptr<CFileItem>& item,
40 const std::string& player,
41 ContentUtils::PlayMode mode = ContentUtils::PlayMode::CHECK_AUTO_PLAY_NEXT_ITEM);
43 enum class QueuePosition
45 POSITION_BEGIN, // place at begin of queue, before other items
46 POSITION_END, // place at end of queue, after other items
49 /*! \brief Queue the given item in the currently active playlist. If no playlist is active,
50 put the item into the video playlist.
51 \param item [in] the item to queue
52 \param pos [in] whether to place the item and the begin or the end of the queue
54 void QueueItem(const std::shared_ptr<CFileItem>& item, QueuePosition pos);
56 /*! \brief For a given item, get the items to put in a playlist. If the item is a folder, all
57 subitems will be added recursively to the returned item list. If the item is a playlist, the
58 playlist will be loaded and contained items will be added to the returned item list. Shows a
59 busy dialog if action takes certain amount of time to give the user visual feedback.
60 \param item [in] the item to add to the playlist
61 \param queuedItems [out] the items that can be put in a play list
62 \return true on success, false otherwise
64 bool GetItemsForPlayList(const std::shared_ptr<CFileItem>& item, CFileItemList& queuedItems);
66 /*!
67 \brief Check whether the given item can be played by the app playlist player as one or more videos.
68 \param item The item to check
69 \return True if playable, false otherwise.
71 bool IsItemPlayable(const CFileItem& item);
73 struct ResumeInformation
75 bool isResumable{false}; // the playback of the item can be resumed
76 int64_t startOffset{0}; // a start offset
77 int partNumber{0}; // a part number
80 /*!
81 \brief Check whether playback of the given item can be resumed, get detailed information.
82 \param item The item to retrieve information for
83 \return The resume information.
85 ResumeInformation GetItemResumeInformation(const CFileItem& item);
87 /*!
88 \brief Get a localized resume string for the given item, if it is resumable.
89 \param item The item to retrieve the resume string for
90 \return The resume string or empty string in case the item is not resumable.
92 std::string GetResumeString(const CFileItem& item);
94 /*!
95 \brief Get resume information for a part of a stack item.
96 \param item The stack item to retrieve information for
97 \param partNumber The number of the part
98 \return The resume information.
100 ResumeInformation GetStackPartResumeInformation(const CFileItem& item, unsigned int partNumber);
102 } // namespace VIDEO_UTILS