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.
9 #include "PlayerUtils.h"
12 #include "ServiceBroker.h"
13 #include "application/ApplicationPlayer.h"
14 #include "cores/playercorefactory/PlayerCoreFactory.h"
15 #include "music/MusicUtils.h"
16 #include "utils/Variant.h"
17 #include "video/VideoFileItemClassify.h"
18 #include "video/guilib/VideoGUIUtils.h"
22 bool CPlayerUtils::IsItemPlayable(const CFileItem
& itemIn
)
24 const CFileItem
item(itemIn
.GetItemToPlay());
27 if (item
.IsParentFolder())
31 if (item
.IsPlugin() && item
.GetProperty("isplayable").asBoolean())
35 if (MUSIC_UTILS::IsItemPlayable(item
))
38 // Movies / TV Shows / Music Videos
39 if (VIDEO::UTILS::IsItemPlayable(item
))
42 //! @todo add more types on demand.
47 void CPlayerUtils::AdvanceTempoStep(const std::shared_ptr
<CApplicationPlayer
>& appPlayer
,
48 TempoStepChange change
)
50 const auto step
= 0.1f
;
51 const auto currentTempo
= appPlayer
->GetPlayTempo();
54 case TempoStepChange::INCREASE
:
55 appPlayer
->SetTempo(currentTempo
+ step
);
57 case TempoStepChange::DECREASE
:
58 appPlayer
->SetTempo(currentTempo
- step
);
63 std::vector
<std::string
> CPlayerUtils::GetPlayersForItem(const CFileItem
& item
)
65 const CPlayerCoreFactory
& playerCoreFactory
{CServiceBroker::GetPlayerCoreFactory()};
67 std::vector
<std::string
> players
;
68 if (VIDEO::IsVideoDb(item
))
70 //! @todo CPlayerCoreFactory and classes called from there do not handle dyn path correctly.
71 CFileItem item2
{item
};
72 item2
.SetPath(item
.GetDynPath());
73 playerCoreFactory
.GetPlayers(item2
, players
);
77 playerCoreFactory
.GetPlayers(item
, players
);
83 bool CPlayerUtils::HasItemMultiplePlayers(const CFileItem
& item
)
85 return GetPlayersForItem(item
).size() > 1;