Tizen WASM Player
Tizen TV WebAssembly Media Player extension allowing for a low-level elementary media stream playback.
samsung::html::HTMLMediaElement Class Referencefinal

Wraps HTMLMediaElement so that it can be used in WebAssembly code. More...

#include <html_media_element.h>

Public Types

enum  ReadyState {

Public Member Functions

 HTMLMediaElement (const char *id)
 HTMLMediaElement (const HTMLMediaElement &)=delete
 HTMLMediaElement (HTMLMediaElement &&)
HTMLMediaElementoperator= (const HTMLMediaElement &)=delete
HTMLMediaElementoperator= (HTMLMediaElement &&)
 ~HTMLMediaElement ()
bool IsValid () const
wasm::Result< bool > IsAutoplay () const
wasm::Result< void > SetAutoplay (bool new_autoplay)
wasm::Result< wasm::SecondsGetCurrentTime () const
wasm::Result< void > SetCurrentTime (wasm::Seconds new_time)
wasm::Result< wasm::SecondsGetDuration () const
wasm::Result< bool > IsEnded () const
wasm::Result< bool > IsLoop () const
wasm::Result< void > SetLoop (bool new_loop)
wasm::Result< bool > IsPaused () const
wasm::Result< ReadyStateGetReadyState () const
wasm::Result< std::string > GetSrc () const
bool HasSrc () const
wasm::Result< void > SetSrc (wasm::ElementaryMediaStreamSource *source)
wasm::Result< void > Play (std::function< void(wasm::OperationResult)> finished_callback)
wasm::Result< void > Pause ()
wasm::Result< void > SetListener (HTMLMediaElementListener *listener)


class wasm::ElementaryMediaStreamSource

Detailed Description

Wraps HTMLMediaElement so that it can be used in WebAssembly code.

HTMLMediaElement is used with wasm::ElementaryMediaStreamSource and it acts as a playback control element, providing operations like play, pause, seek, etc. That is, HTMLMediaElement controls Media Player.

HTMLMediaElement is associated with either <audio> or <video> tag in HTML, allowing to position playback area. Relevant part of HTMLMediaElement WebAPI is wrapped by the class below.

See also
HTMLMediaElement documentation on MDN

Definition at line 53 of file html_media_element.h.

Member Enumeration Documentation

◆ ReadyState


Definition at line 55 of file html_media_element.h.

Constructor & Destructor Documentation

◆ HTMLMediaElement() [1/3]

samsung::html::HTMLMediaElement::HTMLMediaElement ( const char *  id)

Constructs HTMLMediaElement corresponding to a HTML element with a given id. Provided element must exist, otherwise object will be ill-constructed.

[in]idId of either <audio> or <video> HTML element.

◆ HTMLMediaElement() [2/3]

samsung::html::HTMLMediaElement::HTMLMediaElement ( const HTMLMediaElement )

◆ HTMLMediaElement() [3/3]

samsung::html::HTMLMediaElement::HTMLMediaElement ( HTMLMediaElement &&  )

◆ ~HTMLMediaElement()

samsung::html::HTMLMediaElement::~HTMLMediaElement ( )

Member Function Documentation

◆ GetCurrentTime()

wasm::Result<wasm::Seconds> samsung::html::HTMLMediaElement::GetCurrentTime ( ) const

◆ GetDuration()

wasm::Result<wasm::Seconds> samsung::html::HTMLMediaElement::GetDuration ( ) const

◆ GetReadyState()

wasm::Result<ReadyState> samsung::html::HTMLMediaElement::GetReadyState ( ) const

◆ GetSrc()

wasm::Result<std::string> samsung::html::HTMLMediaElement::GetSrc ( ) const

◆ HasSrc()

bool samsung::html::HTMLMediaElement::HasSrc ( ) const

◆ IsAutoplay()

wasm::Result<bool> samsung::html::HTMLMediaElement::IsAutoplay ( ) const

◆ IsEnded()

wasm::Result<bool> samsung::html::HTMLMediaElement::IsEnded ( ) const

◆ IsLoop()

wasm::Result<bool> samsung::html::HTMLMediaElement::IsLoop ( ) const

◆ IsPaused()

wasm::Result<bool> samsung::html::HTMLMediaElement::IsPaused ( ) const

◆ IsValid()

bool samsung::html::HTMLMediaElement::IsValid ( ) const

Returns true if this instance is valid. This method should be called after constructor to ensure the object was properly initialized. If object is invalid all method calls will fail.

true if this instance is valid, otherwise false.

◆ operator=() [1/2]

HTMLMediaElement& samsung::html::HTMLMediaElement::operator= ( const HTMLMediaElement )

◆ operator=() [2/2]

HTMLMediaElement& samsung::html::HTMLMediaElement::operator= ( HTMLMediaElement &&  )

◆ Pause()

wasm::Result<void> samsung::html::HTMLMediaElement::Pause ( )

◆ Play()

wasm::Result<void> samsung::html::HTMLMediaElement::Play ( std::function< void(wasm::OperationResult)>  finished_callback)

◆ SetAutoplay()

wasm::Result<void> samsung::html::HTMLMediaElement::SetAutoplay ( bool  new_autoplay)

◆ SetCurrentTime()

wasm::Result<void> samsung::html::HTMLMediaElement::SetCurrentTime ( wasm::Seconds  new_time)

◆ SetListener()

wasm::Result<void> samsung::html::HTMLMediaElement::SetListener ( HTMLMediaElementListener listener)

Sets a listener to receive updates about HTMLMediaElement. Only one listener can be set: setting another clears the previous one. Pass nullptr to reset the listener.

[in]listenerListener to be set or nullptr to unset the listener.
The ownership isn't transferred, and, as such, the listener must outlive the source.
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.
See also

◆ SetLoop()

wasm::Result<void> samsung::html::HTMLMediaElement::SetLoop ( bool  new_loop)

◆ SetSrc()

wasm::Result<void> samsung::html::HTMLMediaElement::SetSrc ( wasm::ElementaryMediaStreamSource source)

Sets wasm::ElementaryMediaStreamSource object as the current source of playback data. This is equivalent of

mediaElement.src = URL.createObjectURL(elementaryMediaStreamSource);

in JS. URL is maintained by wasm::ElementaryMediaStreamSource and is not revoked manually.

This method doesn't take ownership of wasm::ElementaryMediaStreamSource object. It is imperative that the underlying HTML object (HTMLMediaElement) outlives wasm::ElementaryMediaStreamSource.
[in]sourceNew source to be set.
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.

Friends And Related Function Documentation

◆ wasm::ElementaryMediaStreamSource

friend class wasm::ElementaryMediaStreamSource

Definition at line 155 of file html_media_element.h.

The documentation for this class was generated from the following file: