Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp

Issue 946503003: Add HTMLMediaElement.waitingforkey event (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename again Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp
diff --git a/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp b/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp
index 4bf8eab1268fdbbe30feddd961c7c9f090cfb7f1..b984820213346190432535a41f82dbeaf38f5ac0 100644
--- a/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp
+++ b/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp
@@ -248,6 +248,7 @@ void SetMediaKeysHandler::trace(Visitor* visitor)
HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia()
: m_emeMode(EmeModeNotSelected)
+ , m_isWaitingForKey(false)
{
}
@@ -536,6 +537,44 @@ void HTMLMediaElementEncryptedMedia::encrypted(HTMLMediaElement& element, const
}
}
+void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey(HTMLMediaElement& element)
+{
+ WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey");
+
+ // From https://w3c.github.io/encrypted-media/#queue-waitingforkey:
+ // It should only be called when the HTMLMediaElement object is potentially
+ // playing and its readyState is equal to HAVE_FUTURE_DATA or greater.
+ // FIXME: Is this really required?
+
+ // 1. Let the media element be the specified HTMLMediaElement object.
+ HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element);
+
+ // 2. If the media element's waiting for key value is false, queue a task
+ // to fire a simple event named waitingforkey at the media element.
+ if (!thisElement.m_isWaitingForKey) {
+ RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::waitingforkey);
+ event->setTarget(&element);
+ element.scheduleEvent(event.release());
+ }
+
+ // 3. Set the media element's waiting for key value to true.
+ thisElement.m_isWaitingForKey = true;
+
+ // 4. Suspend playback.
+ // (Already done on the Chromium side by the decryptors.)
+}
+
+void HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey(HTMLMediaElement& element)
+{
+ WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey");
+
+ // Logic is on the Chromium side to attempt to resume playback when a new
+ // key is available. However, |m_isWaitingForKey| needs to be cleared so
+ // that a later waitingForKey() call can generate the event.
+ HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element);
+ thisElement.m_isWaitingForKey = false;
+}
+
void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element)
{
#if ENABLE(OILPAN)
« no previous file with comments | « Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h ('k') | Source/web/WebMediaPlayerClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698