Commit 41d134f6 authored by yoshiki's avatar yoshiki Committed by Commit bot

Video Player: Prevent showing the status icon on unnecessary timing

Sometimes, the status icon was shown in unexpected timing. This might be because the animation is re-fired when the dom is restyled. This patch fixes it.

BUG=none
TEST=Open window->play video->pause->close window. Repeat it 20 times and observe no issue.

Review URL: https://codereview.chromium.org/573233002

Cr-Commit-Position: refs/heads/master@{#295895}
parent 691d6d9f
...@@ -521,10 +521,12 @@ ...@@ -521,10 +521,12 @@
} }
.playback-state-icon { .playback-state-icon {
-webkit-animation: none;
background-color: #202020; background-color: #202020;
background-position: center center; background-position: center center;
background-repeat: no-repeat; background-repeat: no-repeat;
border-radius: 2.5px; border-radius: 2.5px;
display: none;
height: 32px; height: 32px;
left: 50%; left: 50%;
margin-left: -16px; margin-left: -16px;
...@@ -560,7 +562,7 @@ ...@@ -560,7 +562,7 @@
} }
.playback-state-icon[state] { .playback-state-icon[state] {
-webkit-animation: blowup 500ms; display: block;
} }
@-webkit-keyframes blowup { @-webkit-keyframes blowup {
...@@ -593,12 +595,14 @@ ...@@ -593,12 +595,14 @@
} }
.playback-state-icon[state='play'] { .playback-state-icon[state='play'] {
-webkit-animation: blowup 500ms;
background-image: -webkit-image-set( background-image: -webkit-image-set(
url('../images/media/media_play.png') 1x, url('../images/media/media_play.png') 1x,
url('../images/media/2x/media_play.png') 2x); url('../images/media/2x/media_play.png') 2x);
} }
.playback-state-icon[state='pause'] { .playback-state-icon[state='pause'] {
-webkit-animation: blowup 500ms;
background-image: -webkit-image-set( background-image: -webkit-image-set(
url('../images/media/media_pause.png') 1x, url('../images/media/media_pause.png') 1x,
url('../images/media/2x/media_pause.png') 2x); url('../images/media/2x/media_pause.png') 2x);
......
...@@ -1013,9 +1013,22 @@ VideoControls.prototype = { __proto__: MediaControls.prototype }; ...@@ -1013,9 +1013,22 @@ VideoControls.prototype = { __proto__: MediaControls.prototype };
* @private * @private
*/ */
VideoControls.prototype.showIconFeedback_ = function() { VideoControls.prototype.showIconFeedback_ = function() {
this.stateIcon_.removeAttribute('state'); var stateIcon = this.stateIcon_;
stateIcon.removeAttribute('state');
setTimeout(function() { setTimeout(function() {
this.stateIcon_.setAttribute('state', this.isPlaying() ? 'play' : 'pause'); var newState = this.isPlaying() ? 'play' : 'pause';
var onAnimationEnd = function(state, event) {
if (stateIcon.getAttribute('state') === state)
stateIcon.removeAttribute('state');
stateIcon.removeEventListener('webkitAnimationEnd', onAnimationEnd);
}.bind(null, newState);
stateIcon.addEventListener('webkitAnimationEnd', onAnimationEnd);
// Shows the icon with animation.
stateIcon.setAttribute('state', newState);
}.bind(this), 0); }.bind(this), 0);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment