Browse Source

Fixes early initial pause event, may lead to player keep buffering without starting.

j8
damencho 9 years ago
parent
commit
9efebc3702
1 changed files with 11 additions and 1 deletions
  1. 11
    1
      modules/UI/shared_video/SharedVideo.js

+ 11
- 1
modules/UI/shared_video/SharedVideo.js View File

@@ -96,9 +96,19 @@ export default class SharedVideoManager {
96 96
                 });
97 97
             };
98 98
 
99
+        // whether we should pause the player as initial status
100
+        // sometimes if we try to pause the player before it starts playing
101
+        // we can end up with player in buffering mode
102
+        this.initialPause = false;
99 103
         window.onPlayerStateChange = function(event) {
100 104
             if (event.data == YT.PlayerState.PLAYING) {
101 105
                 self.playerPaused = false;
106
+
107
+                // check for initial pause
108
+                if(self.initialPause) {
109
+                    self.initialPause = false;
110
+                    self.player.pauseVideo();
111
+                }
102 112
                 self.updateCheck();
103 113
             } else if (event.data == YT.PlayerState.PAUSED) {
104 114
                 self.playerPaused = true;
@@ -134,7 +144,7 @@ export default class SharedVideoManager {
134 144
 
135 145
             // set initial state of the player if there is enough information
136 146
             if(attributes.state === 'pause')
137
-                player.pauseVideo();
147
+                self.initialPause = true;
138 148
             else if(attributes.time > 0) {
139 149
                 console.log("Player seekTo:", attributes.time);
140 150
                 player.seekTo(attributes.time);

Loading…
Cancel
Save