Shaka Player Embedded
vtt_cue.h
Go to the documentation of this file.
1 // Copyright 2016 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_JS_VTT_CUE_H_
16 #define SHAKA_EMBEDDED_JS_VTT_CUE_H_
17 
18 #include <memory>
19 #include <string>
20 
21 #include "shaka/media/vtt_cue.h"
22 #include "shaka/variant.h"
25 #include "src/mapping/enum.h"
26 
27 namespace shaka {
28 namespace js {
29 
30 enum class AutoKeyword {
31  Auto,
32 };
33 
34 class VTTCue : public BackingObject {
36 
37  public:
38  VTTCue(double start_time, double end_time, const std::string& text);
39  explicit VTTCue(std::shared_ptr<shaka::media::VTTCue> pub);
40 
41  static VTTCue* Create(double start, double end, const std::string& text) {
42  return new VTTCue(start, end, text);
43  }
44 
45  std::shared_ptr<shaka::media::VTTCue> GetPublic() const {
46  return cue_;
47  }
48 
49  std::string id() const;
50  void SetId(const std::string& id);
51  double start_time() const;
52  void SetStartTime(double time);
53  double end_time() const;
54  void SetEndTime(double time);
55  bool pause_on_exit() const;
56  void SetPauseOnExit(bool pause);
57 
58  media::DirectionSetting vertical() const;
59  void SetVertical(media::DirectionSetting setting);
60  bool snap_to_lines() const;
61  void SetSnapToLines(bool snap);
62  media::LineAlignSetting line_align() const;
63  void SetLineAlign(media::LineAlignSetting align);
64  variant<double, AutoKeyword> line() const;
65  void SetLine(variant<double, AutoKeyword> value);
66  variant<double, AutoKeyword> position() const;
67  void SetPosition(variant<double, AutoKeyword> value);
68  media::PositionAlignSetting position_align() const;
69  void SetPositionAlign(media::PositionAlignSetting align);
70  double size() const;
71  void SetSize(double size);
72  media::AlignSetting align() const;
73  void SetAlign(media::AlignSetting align);
74  std::string text() const;
75  void SetText(const std::string& text);
76 
77  private:
78  std::shared_ptr<shaka::media::VTTCue> cue_;
79 };
80 
81 class VTTCueFactory : public BackingObjectFactory<VTTCue> {
82  public:
83  VTTCueFactory();
84 };
85 
86 } // namespace js
87 } // namespace shaka
88 
90  AddMapping(Enum::Auto, "auto");
91 }
92 
94  AddMapping(Enum::Horizontal, "");
95  AddMapping(Enum::LeftToRight, "lr");
96  AddMapping(Enum::RightToLeft, "rl");
97 }
98 
100  AddMapping(Enum::Start, "start");
101  AddMapping(Enum::Center, "center");
102  AddMapping(Enum::End, "end");
103 }
104 
106  AddMapping(Enum::LineLeft, "line-left");
107  AddMapping(Enum::Center, "center");
108  AddMapping(Enum::LineRight, "line-right");
109  AddMapping(Enum::Auto, "auto");
110 }
111 
113  AddMapping(Enum::Start, "start");
114  AddMapping(Enum::Center, "center");
115  AddMapping(Enum::End, "end");
116  AddMapping(Enum::Left, "left");
117  AddMapping(Enum::Right, "right");
118 }
119 
120 #endif // SHAKA_EMBEDDED_JS_VTT_CUE_H_
DEFINE_ENUM_MAPPING(shaka::js, AutoKeyword)
Definition: vtt_cue.h:89
static VTTCue * Create(double start, double end, const std::string &text)
Definition: vtt_cue.h:41
std::shared_ptr< shaka::media::VTTCue > GetPublic() const
Definition: vtt_cue.h:45
DirectionSetting
Definition: vtt_cue.h:31
LineAlignSetting
Definition: vtt_cue.h:58
AutoKeyword
Definition: vtt_cue.h:30
Definition: data.h:29
#define DECLARE_TYPE_INFO(type)
PositionAlignSetting
Definition: vtt_cue.h:82