[Windows] Remove redundant DirectSound error codes
[xbmc.git] / xbmc / video / guilib / VideoPlayActionProcessor.cpp
blob0d2c61897e95769c806cd7ba4754a829951af3ae
1 /*
2 * Copyright (C) 2023 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 #include "VideoPlayActionProcessor.h"
11 #include "FileItem.h"
12 #include "ServiceBroker.h"
13 #include "dialogs/GUIDialogContextMenu.h"
14 #include "settings/Settings.h"
15 #include "settings/SettingsComponent.h"
16 #include "video/guilib/VideoGUIUtils.h"
17 #include "video/guilib/VideoVersionHelper.h"
19 namespace KODI::VIDEO::GUILIB
22 Action CVideoPlayActionProcessorBase::GetDefaultAction()
24 return static_cast<Action>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(
25 CSettings::SETTING_MYVIDEOS_PLAYACTION));
28 bool CVideoPlayActionProcessorBase::ProcessDefaultAction()
30 return ProcessAction(GetDefaultAction());
33 bool CVideoPlayActionProcessorBase::ProcessAction(Action action)
35 m_userCancelled = false;
37 const auto movie{CVideoVersionHelper::ChooseVideoFromAssets(m_item)};
38 if (movie)
39 m_item = movie;
40 else
42 m_userCancelled = true;
43 return true; // User cancelled the select menu. We're done.
46 return Process(action);
49 bool CVideoPlayActionProcessorBase::Process(Action action)
51 switch (action)
53 case ACTION_PLAY_OR_RESUME:
55 const Action selectedAction = ChoosePlayOrResume(*m_item);
56 if (selectedAction < 0)
58 m_userCancelled = true;
59 return true; // User cancelled the select menu. We're done.
62 return Process(selectedAction);
65 case ACTION_RESUME:
66 return OnResumeSelected();
68 case ACTION_PLAY_FROM_BEGINNING:
69 return OnPlaySelected();
71 default:
72 break;
74 return false; // We did not handle the action.
77 Action CVideoPlayActionProcessorBase::ChoosePlayOrResume(const CFileItem& item)
79 Action action = ACTION_PLAY_FROM_BEGINNING;
81 const std::string resumeString = VIDEO::UTILS::GetResumeString(item);
82 if (!resumeString.empty())
84 CContextButtons choices;
86 choices.Add(ACTION_RESUME, resumeString);
87 choices.Add(ACTION_PLAY_FROM_BEGINNING, 12021); // Play from beginning
89 action = static_cast<Action>(CGUIDialogContextMenu::ShowAndGetChoice(choices));
92 return action;
95 } // namespace KODI::VIDEO::GUILIB