Bug 1244768 part 7 - refactor the Play() and PlayInternal() methods; r=jwwang
MozReview-Commit-ID: CP00vERdWMv
This commit is contained in:
@@ -3698,17 +3698,16 @@ HTMLMediaElement::Play(ErrorResult& aRv)
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = PlayInternal();
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
PlayInternal(aRv);
|
||||
|
||||
UpdateCustomPolicyAfterPlayed();
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLMediaElement::PlayInternal()
|
||||
void
|
||||
HTMLMediaElement::PlayInternal(ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(!aRv.Failed());
|
||||
|
||||
if (!IsAllowedToPlay()) {
|
||||
// NOTE: for promise-based-play, will return a rejected promise here.
|
||||
return NS_OK;
|
||||
@@ -3734,7 +3733,8 @@ HTMLMediaElement::PlayInternal()
|
||||
if (!mPausedForInactiveDocumentOrChannel) {
|
||||
nsresult rv = mDecoder->Play();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
aRv.Throw(rv);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3774,7 +3774,7 @@ HTMLMediaElement::PlayInternal()
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3793,9 +3793,10 @@ NS_IMETHODIMP HTMLMediaElement::Play()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = PlayInternal();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
ErrorResult rv;
|
||||
PlayInternal(rv);
|
||||
if (rv.Failed()) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
UpdateCustomPolicyAfterPlayed();
|
||||
|
||||
Reference in New Issue
Block a user