This topic covers how to start media playback in Tizen WASM Player.
The process of starting playback differs between the different WASM Player latency modes.
Normal Latency Mode
Normal latency playback in the WASM Player is meant for VOD scenarios. In this mode, the platform's Media Player buffers Elementary Media Packet data sent by the application and ensures it plays smoothly.
Once ElementaryMediaStreamSource enters ReadyState::kOpen (thus opening ElementaryMediaTrack), the application can start buffering media data. In normal latency mode, several packets need to be buffered and processed by the platform before the playback can be started. The application must either observe HTMLMediaElement events (HTMLMediaElementListener::OnCanPlay()) to detect this moment or use the HTMLMediaElement autoplay feature.
ImportantIn normal latency mode, the opening and closing of ElementaryMediaStreamSource and ElementaryMediaTrack objects are not in sync with HTMLMediaElementListener::OnCanPlay(). The WASM Player objects open when the platform is ready to receive media data, and leave the Open state when packets cannot be received anymore. Elementary Media Packets that are sent affect both the ready state and events emitted by HTMLMediaElement, depending on the platform's internal media data buffer level. Therefore, the application must observe HTMLMediaElement through HTMLMediaElementListener for the complete Media Player state.
The source enters ReadyState::kOpen and each track emits an ElementaryMediaTrackListener::OnTrackOpen() event to notify that it can accept elementary media data.
class MyTrackListener : public samsung::wasm::ElementaryMediaTrackListener {
// ...
void OnTrackOpen() override {
// Start the application's packet sending mechanism for the associated track
}
// ...
};
NoteAlternatively, the application can wait for an ElementaryMediaStreamSourceListener::OnSourceOpen() event emitted by the source itself. OnTrackOpen events are generated before OnSourceOpen, so it's safe to trigger the packet sending mechanism in this event handler too.
ImportantOnTrackOpen and OnSourceOpen events are generated whenever a track opens: starting playback after initialization is the most prominent case, but they also trigger, for example, during a Seek operation when the application is multitasking. No matter the reason, the first packet sent to a newly opened ElementaryMediaTrack must be a keyframe.
Build up the internal Media Player data buffer by sending several packets. This is basically the same mechanism as described below in Sending Elementary Media Packets.
When HTMLMediaElement is ready to start playback, it emits an HTMLMediaElementListener::OnCanPlay() event. Handle the event and call HTMLMediaElement::Play().
class MyMediaElementListener : public samsung::html::HTMLMediaElementListener {
// ...
void OnCanPlay() override {
html_media_element->Play([](OperationResult result) {
if (result != OperationResult::kSuccess) {
// Handle error
}
});
}
// ...
};
Low latency playback in the WASM Player is meant for live streaming scenarios. In this mode the platform renders Elementary Media Packets immediately after the application sends them. Therefore it is up to the application to maintain the pipeline clock and stream synchronization.
In low latency modes, no buffering is required to start media playback. Media Player is ready to start playback at any moment, however WASM Player can accept packets only when HTMLMediaElement is in the Playing state.
When ElementaryMediaStreamSource::Open() is called, ElementaryMediaStreamSource is immediately set in the ReadyState::kOpenPending state. Once the application calls HTMLMediaElement::Play(), the source enters ReadyState::kOpen state and the ElementaryMediaTrack objects open. From that point on, Elementary Media Packets are accepted and rendered immediately.
The source enters ReadyState::kOpen and each track emits ElementaryMediaTrackListener::OnTrackOpen() event to notify it can accept elementary media data.
class MyTrackListener : public samsung::wasm::ElementaryMediaTrackListener {
// ...
void OnTrackOpen() override {
// Start the application's packet sending mechanism for the associated track
}
// ...
};
NoteAlternatively, the application can wait for an ElementaryMediaStreamSourceListener::OnSourceOpen() event emitted by the source itself. OnTrackOpen events are generated before OnSourceOpen, so it's safe to trigger packet sending mechanism in this event handler too.
ImportantOnTrackOpen and OnSourceOpen events are generated whenever a track opens: starting playback after initialization is the most prominent case, but both also trigger, for example, when playback is paused and then unpaused, or the application is multitasking. No matter the reason, the first packet sent to a newly opened ElementaryMediaTrack must be a keyframe.
Manage Your Cookies
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.