Bug 1309162 - part7 : wrap custom policy function.
MozReview-Commit-ID: EdjzMi90ukx
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3568,20 +3568,17 @@ HTMLMediaElement::Play(ErrorResult& aRv)
return;
}
nsresult rv = PlayInternal();
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
- OpenUnsupportedMediaWithExternalAppIfNeeded();
- if (mAudioChannelWrapper) {
- mAudioChannelWrapper->NotifyPlayStarted();
- }
+ UpdateCustomPolicyAfterPlayed();
}
nsresult
HTMLMediaElement::PlayInternal()
{
// Play was not blocked so assume user interacted with the element.
mHasUserInteraction = true;
@@ -3660,20 +3657,17 @@ NS_IMETHODIMP HTMLMediaElement::Play()
return NS_OK;
}
nsresult rv = PlayInternal();
if (NS_FAILED(rv)) {
return rv;
}
- OpenUnsupportedMediaWithExternalAppIfNeeded();
- if (mAudioChannelWrapper) {
- mAudioChannelWrapper->NotifyPlayStarted();
- }
+ UpdateCustomPolicyAfterPlayed();
return NS_OK;
}
HTMLMediaElement::WakeLockBoolWrapper&
HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val)
{
if (mValue == val) {
return *this;
@@ -6858,10 +6852,19 @@ HTMLMediaElement::MarkAsContentSource(Ca
}
}
LOG(LogLevel::Debug,
("%p Log VIDEO_AS_CONTENT_SOURCE: visibility = %u, API: '%d' and 'All'",
this, isVisible, aAPI));
}
+void
+HTMLMediaElement::UpdateCustomPolicyAfterPlayed()
+{
+ OpenUnsupportedMediaWithExternalAppIfNeeded();
+ if (mAudioChannelWrapper) {
+ mAudioChannelWrapper->NotifyPlayStarted();
+ }
+}
+
} // namespace dom
} // namespace mozilla
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -1222,16 +1222,19 @@ protected:
void AudioCaptureStreamChange(bool aCapture);
// A method to check whether the media element is allowed to start playback.
bool IsAllowedToPlay();
// If the network state is empty and then we would trigger DoLoad().
void MaybeDoLoad();
+ // Anything we need to check after played success and not related with spec.
+ void UpdateCustomPolicyAfterPlayed();
+
class nsAsyncEventRunner;
using nsGenericHTMLElement::DispatchEvent;
// For nsAsyncEventRunner.
nsresult DispatchEvent(const nsAString& aName);
// Open unsupported types media with the external app when the media element
// triggers play() after loaded fail. eg. preload the data before start play.
void OpenUnsupportedMediaWithExternalAppIfNeeded() const;