Tizen WASM Player
Tizen TV WebAssembly Media Player extension allowing for a low-level elementary media stream playback.
html_media_element.h
Go to the documentation of this file.
1 // Copyright 2020 Samsung Electronics
2 // TizenTV Emscripten extensions are available under two separate licenses, the
3 // MIT license and the University of Illinois/NCSA Open Source License. Both
4 // these licenses can be found in the LICENSE file.
5 
6 #ifndef INCLUDE_SAMSUNG_HTML_HTML_MEDIA_ELEMENT_H_
7 #define INCLUDE_SAMSUNG_HTML_HTML_MEDIA_ELEMENT_H_
8 
9 #include <functional>
10 #include <string>
11 
12 #include "samsung/wasm/common.h"
14 
15 namespace samsung {
16 
17 namespace wasm {
18 
21 enum class OperationResult;
22 
23 } // namespace wasm
24 
25 namespace html {
26 
28 
53 class HTMLMediaElement final {
54  public:
55  enum class ReadyState {
56  kHaveNothing,
57  kHaveMetadata,
58  kHaveCurrentData,
59  kHaveFutureData,
60  kHaveEnoughData,
61  };
62 
67  explicit HTMLMediaElement(const char* id);
68  HTMLMediaElement(const HTMLMediaElement&) = delete;
70  HTMLMediaElement& operator=(const HTMLMediaElement&) = delete;
71  HTMLMediaElement& operator=(HTMLMediaElement&&);
73 
79  bool IsValid() const;
80 
81  wasm::Result<bool> IsAutoplay() const;
82  wasm::Result<void> SetAutoplay(bool new_autoplay);
83 
84  wasm::Result<wasm::Seconds> GetCurrentTime() const;
85  wasm::Result<void> SetCurrentTime(wasm::Seconds new_time);
86 
87  wasm::Result<wasm::Seconds> GetDuration() const;
88  wasm::Result<bool> IsEnded() const;
89 
90  wasm::Result<bool> IsLoop() const;
91  wasm::Result<void> SetLoop(bool new_loop);
92 
93  wasm::Result<bool> IsPaused() const;
94 
95  wasm::Result<ReadyState> GetReadyState() const;
96 
97  wasm::Result<std::string> GetSrc() const;
98 
99  bool HasSrc() const;
100 
120 
121  wasm::Result<void> Play(
122  std::function<void(wasm::OperationResult)> finished_callback);
123  wasm::Result<void> Pause();
124 
139  wasm::Result<void> SetListener(HTMLMediaElementListener* listener);
140 
141  private:
142  wasm::OperationResult SetListenerInternal(HTMLMediaElementListener* listener);
143 
144  // legacy EMSS compatibility: methods
145  wasm::Result<void> RegisterOnTimeUpdateEMSS(
146  wasm::ElementaryMediaStreamSourceListener*, int source_handle);
147  void UnregisterOnTimeUpdateEMSS(int source_handle);
148 
149  int handle_;
150  HTMLMediaElementListener* listener_;
151 
152  // legacy EMSS compatibility: variables
154 
156 };
157 
158 } // namespace html
159 } // namespace samsung
160 
161 #endif // INCLUDE_SAMSUNG_HTML_HTML_MEDIA_ELEMENT_H_
Main class of WASM Player. ElementaryMediaStreamSource acts as a data source for html::HTMLMediaEleme...
Allows receiving ElementaryMediaStreamSource events.
std::chrono::duration< double > Seconds
Default duration type used throughout the API.
Definition: common.h:53
OperationResult
Enumerates possible outcomes of WASM function calls.
Wraps HTMLMediaElement so that it can be used in WebAssembly code.
Allows receiving HTMLMediaElement events.