зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1302453 - part1 : send new gecko event when media is resumed. r=baku
We uses "media-playback" event to notify fennec media control about media start and end. However, if we resume media which was paused by media control, it won't send any notification to JAVA side so that the MediaControlService can't change the correct playing icon. Therefore, we create new event to inform this situation. MozReview-Commit-ID: zScaHxvHXM --HG-- extra : rebase_source : e1434840de36d8621a58fc7406b0f42673a2f3db
This commit is contained in:
Родитель
f5e82adbfe
Коммит
10ed91bc28
|
@ -37,6 +37,8 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
@ -5945,6 +5947,7 @@ HTMLMediaElement::SetAudioChannelSuspended(SuspendTypes aSuspend)
|
|||
return;
|
||||
}
|
||||
|
||||
MaybeNotifyMediaResumed(aSuspend);
|
||||
mAudioChannelSuspended = aSuspend;
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("HTMLMediaElement, SetAudioChannelSuspended, this = %p, "
|
||||
|
@ -6427,6 +6430,37 @@ HTMLMediaElement::IsAudible() const
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::MaybeNotifyMediaResumed(SuspendTypes aSuspend)
|
||||
{
|
||||
// In fennec, we should send the notification when media is resumed from the
|
||||
// pause-disposable which was called by media control.
|
||||
if (mAudioChannelSuspended != nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE &&
|
||||
aSuspend != nsISuspendedTypes::NONE_SUSPENDED) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t windowID = mAudioChannelAgent->WindowID();
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction([windowID]() -> void {
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
services::GetObserverService();
|
||||
if (NS_WARN_IF(!observerService)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsPRUint64> wrapper =
|
||||
do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID);
|
||||
if (NS_WARN_IF(!wrapper)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper->SetData(windowID);
|
||||
observerService->NotifyObservers(wrapper,
|
||||
"media-playback-resumed",
|
||||
u"active");
|
||||
}));
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLMediaElement::HaveFailedWithSourceNotSupportedError() const
|
||||
{
|
||||
|
|
|
@ -1268,6 +1268,10 @@ protected:
|
|||
|
||||
void OpenUnsupportedMediaWithExtenalAppIfNeeded();
|
||||
|
||||
// It's used for fennec only, send the notification when the user resumes the
|
||||
// media which was paused by media control.
|
||||
void MaybeNotifyMediaResumed(SuspendTypes aSuspend);
|
||||
|
||||
class nsAsyncEventRunner;
|
||||
using nsGenericHTMLElement::DispatchEvent;
|
||||
// For nsAsyncEventRunner.
|
||||
|
|
Загрузка…
Ссылка в новой задаче