#include "wrt/public/browser/wrt.h"
#endif
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "third_party/blink/public/platform/web_application_type.h"
+#endif
+
using base::Time;
using blink::ContextMenuData;
using blink::WebContentDecryptionModule;
observer.ScrollbarThumbPartFocusChanged(orientation, focused);
}
-void RenderFrameImpl::WRTMediaSuspend(bool suspend) {
- LOG(INFO) << "WRTMediaSuspend:" << suspend << ", this:" << (void*)this;
+void RenderFrameImpl::SuspendMediaByHost(bool suspend) {
+ LOG(INFO) << "SuspendMediaByHost: " << suspend << ", this:" << (void*)this;
if (!IsMainFrame()) {
LOG(INFO) << "Not main frame, ignore.";
return;
}
- frame_->GetDocument().WRTMediaSuspend(suspend);
+ frame_->GetDocument().SuspendMediaByHost(suspend);
}
#endif
}
void RenderFrameImpl::WasHidden() {
+ LOG(INFO) << __FUNCTION__ << "[" << (void*)this << "]";
#if BUILDFLAG(IS_TIZEN_TV)
- WRTMediaSuspend(true);
+ if (blink::IsTIZENWRT()) {
+ LOG(INFO) << __func__ << ", WRT case trigger media player suspend";
+ SuspendMediaByHost(true);
+ }
#endif
frame_->WasHidden();
}
void RenderFrameImpl::WasShown() {
+ LOG(INFO) << __FUNCTION__ << "[" << (void*)this << "]";
#if BUILDFLAG(IS_TIZEN_TV)
- WRTMediaSuspend(false);
+ if (blink::IsTIZENWRT()) {
+ LOG(INFO) << __func__ << ", WRT case trigger media player resume";
+ SuspendMediaByHost(false);
+ }
#endif
frame_->WasShown();
is_video_visibility_set_(false),
is_translated_url_(false),
text_track_menu_on_(false),
- suspend_media_by_wrt_(false),
- resume_media_by_wrt_(false),
+ suspended_by_host_(false),
+ resumed_by_host_(false),
#endif
#if defined(TIZEN_MULTIMEDIA)
live_playback_complete_(false),
}
#if defined(TIZEN_MULTIMEDIA)
else if (state == mojom::FrameLifecycleState::kPaused) {
-#if BUILDFLAG(IS_TIZEN_TV)
- resume_media_by_wrt_ = false;
- if (suspend_media_by_wrt_) {
- LOG(INFO) << "Already suspend by WRT, return directly.";
- return;
- }
- suspend_media_by_wrt_ = true;
-#endif
-#if defined(SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE)
- if (media_source_attachment_) {
- // Send suspend event to the source before WebMediaPlayer suspends
- // backend.
- media_source_attachment_->OnSuspend(media_source_tracer_);
- }
-#endif // SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE
- // Suspend if a browser tab is switched.
- if (GetWebMediaPlayer())
- GetWebMediaPlayer()->Suspend();
- else
- LOG(INFO) << "no WebMediaPlayer, ignore.";
-
- if (playing_) {
- paused_by_context_paused_ = true;
- pause();
- }
+ SuspendMediaByHost(true);
} else if (state == mojom::FrameLifecycleState::kRunning) {
-#if BUILDFLAG(IS_TIZEN_TV)
- suspend_media_by_wrt_ = false;
- if (resume_media_by_wrt_) {
- LOG(INFO) << "Already resume by WRT, return directly.";
- return;
- }
- resume_media_by_wrt_ = false;
-#endif
-
- // Do not resume if suspended by player except the resource conflict case.
- if (GetWebMediaPlayer() && GetWebMediaPlayer()->SuspendedByPlayer()) {
- LOG(INFO) << "suspended by player except the resource conflict case, do "
- "not resume.";
- return;
- }
-
- if (GetWebMediaPlayer())
- GetWebMediaPlayer()->Resume();
- else
- LOG(INFO) << "no WebMediaPlayer, ignore.";
-
-#if defined(SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE)
- if (media_source_attachment_) {
- // Send suspend event to the source after WebMediaPlayer resumes backend.
- media_source_attachment_->OnResume(media_source_tracer_);
- }
-#endif // SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE
-
- if (paused_by_context_paused_) {
- paused_by_context_paused_ = false;
- Play();
- }
+ SuspendMediaByHost(false);
}
#else
else if (state == mojom::FrameLifecycleState::kRunning &&
GetWebMediaPlayer()->SetPreferTextLanguage(prefer_text_lang_);
}
-void HTMLMediaElement::WRTMediaSuspend(bool suspend) {
- LOG(INFO) << "WRTMediaSuspend:" << suspend << ",this:" << (void*)this;
+bool HTMLMediaElement::HasEncryptedListener() const {
+ return HasEventListeners(event_type_names::kEncrypted);
+}
+#endif
+
+void HTMLMediaElement::SuspendMediaByHost(bool suspend) {
+ LOG(INFO) << "SuspendMediaByHost: " << suspend << ", this:" << (void*)this;
if (suspend) {
- resume_media_by_wrt_ = false;
- if (suspend_media_by_wrt_) {
+#if BUILDFLAG(IS_TIZEN_TV)
+ resumed_by_host_ = false;
+ if (suspended_by_host_) {
LOG(INFO) << "Already suspend, return directly.";
return;
}
- suspend_media_by_wrt_ = true;
+ suspended_by_host_ = true;
+#endif
#if defined(SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE)
if (media_source_attachment_) {
if (GetWebMediaPlayer())
GetWebMediaPlayer()->Suspend();
else
- LOG(INFO) << "WebMediaPlayer is null";
+ LOG(INFO) << __func__ << ", WebMediaPlayer is null";
if (playing_) {
paused_by_context_paused_ = true;
pause();
}
} else {
- suspend_media_by_wrt_ = false;
- if (resume_media_by_wrt_) {
- LOG(INFO) << "Already resume, return directly.";
+#if BUILDFLAG(IS_TIZEN_TV)
+ suspended_by_host_ = false;
+ if (resumed_by_host_) {
+ LOG(INFO) << __func__ << ", Already resume, return directly.";
return;
}
- resume_media_by_wrt_ = true;
-
-#if defined(SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE)
- if (media_source_attachment_) {
- media_source_attachment_->OnResume(media_source_tracer_);
- }
+ resumed_by_host_ = true;
#endif
if (GetWebMediaPlayer())
GetWebMediaPlayer()->Resume();
else
- LOG(INFO) << "WebMediaPlayer is null";
+ LOG(INFO) << __func__ << ", WebMediaPlayer is null";
+
+#if defined(SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE)
+ if (media_source_attachment_) {
+ // Send suspend event to the source after WebMediaPlayer resumes backend.
+ media_source_attachment_->OnResume(media_source_tracer_);
+ }
+#endif // SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE
if (paused_by_context_paused_) {
paused_by_context_paused_ = false;
}
}
-bool HTMLMediaElement::HasEncryptedListener() const {
- return HasEventListeners(event_type_names::kEncrypted);
-}
-#endif
double HTMLMediaElement::getStartDate() const {
#if BUILDFLAG(IS_TIZEN_TV)
if (!IsHbbTV() || !GetWebMediaPlayer()) {