diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 920b1099ef42..7c2f622c1c83 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -2402,6 +2402,27 @@ _setvalue(NPP npp, NPPVariable variable, void *result) return inst->SetUsesDOMForCursor(useDOMForCursor); } + case NPPVpluginIsPlayingAudio: { + // For testing, remove me + printf("set audio %p\n", result); + bool isPlaying = !!result; + + nsCOMPtr doc = GetDocumentFromNPP(npp); + if (doc) { + nsCOMPtr domwindow = doc->GetWindow(); + nsCOMPtr observerService = + services::GetObserverService(); + if (observerService) { + // XXX THIS NEEDS A BETTER API + observerService->NotifyObservers(ToSupports(domwindow), + "media-playback", + isPlaying ? NS_LITERAL_STRING("active").get() : + NS_LITERAL_STRING("inactive").get()); + } + } + return NPERR_NO_ERROR; + } + #ifndef MOZ_WIDGET_ANDROID // On android, their 'drawing model' uses the same constant! case NPPVpluginDrawingModel: { diff --git a/dom/plugins/ipc/PPluginInstance.ipdl b/dom/plugins/ipc/PPluginInstance.ipdl index 3a4a3d521da9..8db84097b6c1 100644 --- a/dom/plugins/ipc/PPluginInstance.ipdl +++ b/dom/plugins/ipc/PPluginInstance.ipdl @@ -150,6 +150,8 @@ parent: returns (NPError result); intr NPN_SetValue_NPPVpluginEventModel(int eventModel) returns (NPError result); + intr NPN_SetValue_NPPVpluginIsPlayingAudio(bool isAudioPlaying) + returns (NPError result); intr NPN_GetURL(nsCString url, nsCString target) returns (NPError result); diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 512db7dba2c9..87b574f3deb9 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -626,6 +626,14 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue) } #endif + case NPPVpluginIsPlayingAudio: { + NPError rv = NPERR_GENERIC_ERROR; + if (!CallNPN_SetValue_NPPVpluginIsPlayingAudio((NPBool)(intptr_t)aValue, &rv)) { + return NPERR_GENERIC_ERROR; + } + return rv; + } + default: MOZ_LOG(GetPluginLog(), LogLevel::Warning, ("In PluginInstanceChild::NPN_SetValue: Unhandled NPPVariable %i (%s)", diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 45c012c40b92..bfaa5061803c 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -440,6 +440,15 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginEventModel( #endif } +bool +PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginIsPlayingAudio( + const bool& isAudioPlaying, NPError* result) +{ + *result = mNPNIface->setvalue(mNPP, NPPVpluginIsPlayingAudio, + (void*)(intptr_t)isAudioPlaying); + return true; +} + bool PluginInstanceParent::AnswerNPN_GetURL(const nsCString& url, const nsCString& target, diff --git a/dom/plugins/ipc/PluginInstanceParent.h b/dom/plugins/ipc/PluginInstanceParent.h index 052408528f17..80af054cf936 100644 --- a/dom/plugins/ipc/PluginInstanceParent.h +++ b/dom/plugins/ipc/PluginInstanceParent.h @@ -128,6 +128,9 @@ public: virtual bool AnswerNPN_SetValue_NPPVpluginEventModel(const int& eventModel, NPError* result) override; + virtual bool + AnswerNPN_SetValue_NPPVpluginIsPlayingAudio(const bool& isAudioPlaying, + NPError* result) override; virtual bool AnswerNPN_GetURL(const nsCString& url, const nsCString& target,