summaryrefslogtreecommitdiffstats
path: root/xbmc/pvr/guilib/PVRGUIActionsPlayback.h
blob: 8b0ab556f2d32dd3f362329d9f06b020abdd2813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 *  Copyright (C) 2016-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "pvr/IPVRComponent.h"
#include "pvr/settings/PVRSettings.h"

#include <string>

class CFileItem;

namespace PVR
{
enum PlaybackType
{
  PlaybackTypeAny = 0,
  PlaybackTypeTV,
  PlaybackTypeRadio
};

class CPVRStreamProperties;

class CPVRGUIActionsPlayback : public IPVRComponent
{
public:
  CPVRGUIActionsPlayback();
  ~CPVRGUIActionsPlayback() override = default;

  /*!
   * @brief Get a localized resume play label, if the given item can be resumed.
   * @param item containing a recording or an epg tag.
   * @return the localized resume play label that can be used for instance as context menu item
   * label or an empty string if resume is not possible.
   */
  std::string GetResumeLabel(const CFileItem& item) const;

  /*!
   * @brief Resume a previously not completely played recording.
   * @param item containing a recording or an epg tag.
   * @param bFallbackToPlay controls whether playback of the recording should be started at the
   * beginning ig no resume data are available.
   * @return true on success, false otherwise.
   */
  bool ResumePlayRecording(const CFileItem& item, bool bFallbackToPlay) const;

  /*!
   * @brief Play recording.
   * @param item containing a recording or an epg tag.
   * @param bCheckResume controls resume check.
   * @return true on success, false otherwise.
   */
  bool PlayRecording(const CFileItem& item, bool bCheckResume) const;

  /*!
   * @brief Play EPG tag.
   * @param item containing an epg tag.
   * @return true on success, false otherwise.
   */
  bool PlayEpgTag(const CFileItem& item) const;

  /*!
   * @brief Switch channel.
   * @param item containing a channel or an epg tag.
   * @param bCheckResume controls resume check in case a recording for the current epg event is
   * present.
   * @return true on success, false otherwise.
   */
  bool SwitchToChannel(const CFileItem& item, bool bCheckResume) const;

  /*!
   * @brief Playback the given file item.
   * @param item containing a channel or a recording.
   * @return True if the item could be played, false otherwise.
   */
  bool PlayMedia(const CFileItem& item) const;

  /*!
   * @brief Start playback of the last played channel, and if there is none, play first channel in
   * the current channelgroup.
   * @param type The type of playback to be started (any, radio, tv). See PlaybackType enum
   * @return True if playback was started, false otherwise.
   */
  bool SwitchToChannel(PlaybackType type) const;

  /*!
   * @brief Plays the last played channel or the first channel of TV or Radio on startup.
   * @return True if playback was started, false otherwise.
   */
  bool PlayChannelOnStartup() const;

  /*!
   * @brief Seek to the start of the next epg event in timeshift buffer, relative to the currently
   * playing event. If there is no next event, seek to the end of the currently playing event (to
   * the 'live' position).
   */
  void SeekForward();

  /*!
   * @brief Seek to the start of the previous epg event in timeshift buffer, relative to the
   * currently playing event or if there is no previous event or if playback time is greater than
   * given threshold, seek to the start of the playing event.
   * @param iThreshold the value in seconds to trigger seek to start of current event instead of
   * start of previous event.
   */
  void SeekBackward(unsigned int iThreshold);

private:
  CPVRGUIActionsPlayback(const CPVRGUIActionsPlayback&) = delete;
  CPVRGUIActionsPlayback const& operator=(CPVRGUIActionsPlayback const&) = delete;

  /*!
   * @brief Check whether resume play is possible for a given item, display "resume from ..."/"play
   * from start" context menu in case.
   * @param item containing a recording or an epg tag.
   * @return true, to play/resume the item, false otherwise.
   */
  bool CheckResumeRecording(const CFileItem& item) const;

  /*!
   * @brief Check "play minimized" settings value and switch to fullscreen if not set.
   * @param bFullscreen switch to fullscreen or set windowed playback.
   */
  void CheckAndSwitchToFullscreen(bool bFullscreen) const;

  /*!
   * @brief Start playback of the given item.
   * @param bFullscreen start playback fullscreen or not.
   * @param epgProps properties to be used instead of calling to the client if supplied.
   * @param item containing a channel or a recording.
   */
  void StartPlayback(CFileItem* item,
                     bool bFullscreen,
                     const CPVRStreamProperties* epgProps = nullptr) const;

  CPVRSettings m_settings;
};

namespace GUI
{
// pretty scope and name
using Playback = CPVRGUIActionsPlayback;
} // namespace GUI

} // namespace PVR