Bläddra i källkod

Merge pull request #573 from damencho/shared-video-updates

Shared video updates
master
yanas 9 år sedan
förälder
incheckning
b7cc03df26
5 ändrade filer med 46 tillägg och 24 borttagningar
  1. 1
    1
      conference.js
  2. 1
    1
      index.html
  3. 1
    1
      lang/main.json
  4. 1
    1
      modules/UI/UI.js
  5. 42
    20
      modules/UI/shared_video/SharedVideo.js

+ 1
- 1
conference.js Visa fil

@@ -1110,7 +1110,7 @@ export default {
1110 1110
             Commands.SHARED_VIDEO, ({value, attributes}, id) => {
1111 1111
 
1112 1112
                 if (attributes.state === 'stop') {
1113
-                    APP.UI.stopSharedVideo(id);
1113
+                    APP.UI.stopSharedVideo(id, attributes);
1114 1114
                 } else if (attributes.state === 'start') {
1115 1115
                     APP.UI.showSharedVideo(id, value, attributes);
1116 1116
                 } else if (attributes.state === 'playing'

+ 1
- 1
index.html Visa fil

@@ -126,7 +126,7 @@
126 126
                         <span id="unreadMessages"></span>
127 127
                     </a>
128 128
                     <a class="button icon-share-doc" id="toolbar_button_etherpad" data-container="body" data-toggle="popover" data-placement="bottom" content="Shared document" data-i18n="[content]toolbar.etherpad"></a>
129
-                    <a class="button fa fa-share-alt-square" id="toolbar_button_sharedvideo" data-container="body" data-toggle="popover" data-placement="bottom" content="Shared Video" data-i18n="[content]toolbar.sharedvideo" style="display: none"></a>
129
+                    <a class="button fa fa-share-alt-square" id="toolbar_button_sharedvideo" data-container="body" data-toggle="popover" data-placement="bottom" content="Share a YouTube video" data-i18n="[content]toolbar.sharedvideo" style="display: none"></a>
130 130
                     <a class="button icon-share-desktop" id="toolbar_button_desktopsharing" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleDesktopSharingPopover" content="Share screen" data-i18n="[content]toolbar.sharescreen" style="display: none"></a>
131 131
                     <a class="button icon-full-screen" id="toolbar_button_fullScreen" data-container="body" data-toggle="popover" data-placement="bottom" content="Enter / Exit Full Screen" data-i18n="[content]toolbar.fullscreen"></a>
132 132
                     <a class="button icon-telephone" id="toolbar_button_sip" data-container="body" data-toggle="popover" data-placement="bottom" content="Call SIP number" data-i18n="[content]toolbar.sip" style="display: none"></a>

+ 1
- 1
lang/main.json Visa fil

@@ -55,7 +55,7 @@
55 55
         "invite": "Invite others",
56 56
         "chat": "Open / close chat",
57 57
         "etherpad": "Shared document",
58
-        "sharedvideo": "Shared video",
58
+        "sharedvideo": "Share a YouTube video",
59 59
         "sharescreen": "Share screen",
60 60
         "fullscreen": "Enter / Exit Full Screen",
61 61
         "sip": "Call SIP number",

+ 1
- 1
modules/UI/UI.js Visa fil

@@ -1115,7 +1115,7 @@ UI.updateSharedVideo = function (id, url, attributes) {
1115 1115
  */
1116 1116
 UI.stopSharedVideo = function (id, attributes) {
1117 1117
     if (sharedVideoManager)
1118
-        sharedVideoManager.stopSharedVideo(id);
1118
+        sharedVideoManager.stopSharedVideo(id, attributes);
1119 1119
 };
1120 1120
 
1121 1121
 module.exports = UI;

+ 42
- 20
modules/UI/shared_video/SharedVideo.js Visa fil

@@ -44,7 +44,8 @@ export default class SharedVideoManager {
44 44
 
45 45
         if(APP.conference.isLocalId(this.from)) {
46 46
             showStopVideoPropmpt().then(() =>
47
-                this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO, null, 'stop'));
47
+                this.emitter.emit(
48
+                    UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'));
48 49
         } else {
49 50
             messageHandler.openMessageDialog(
50 51
                 "dialog.shareVideoTitle",
@@ -64,6 +65,8 @@ export default class SharedVideoManager {
64 65
         if (this.isSharedVideoShown)
65 66
             return;
66 67
 
68
+        this.isSharedVideoShown = true;
69
+
67 70
         // the video url
68 71
         this.url = url;
69 72
 
@@ -82,7 +85,7 @@ export default class SharedVideoManager {
82 85
         // we need to operate with player after start playing
83 86
         // self.player will be defined once it start playing
84 87
         // and will process any initial attributes if any
85
-        this.initialAttributes = null;
88
+        this.initialAttributes = attributes;
86 89
 
87 90
         var self = this;
88 91
         if(self.isPlayerAPILoaded)
@@ -148,8 +151,6 @@ export default class SharedVideoManager {
148 151
                 SHARED_VIDEO_CONTAINER_TYPE, self.sharedVideo);
149 152
             VideoLayout.handleVideoThumbClicked(self.url);
150 153
 
151
-            self.isSharedVideoShown = true;
152
-
153 154
             // If we are sending the command and we are starting the player
154 155
             // we need to continuously send the player current time position
155 156
             if(APP.conference.isLocalId(self.from)) {
@@ -157,17 +158,12 @@ export default class SharedVideoManager {
157 158
                     self.updateCheck.bind(self),
158 159
                     updateInterval);
159 160
             }
160
-
161
-            if(self.player)
162
-                self.processAttributes(
163
-                    self.player, attributes, self.playerPaused);
164
-            else {
165
-                self.initialAttributes = attributes;
166
-            }
167 161
         };
168 162
 
169 163
         window.onPlayerError = function(event) {
170
-            console.error("Error in the player:" + event.data);
164
+            console.error("Error in the player:", event.data);
165
+            // store the error player, so we can remove it
166
+            self.errorInPlayer = event.target;
171 167
         };
172 168
     }
173 169
 
@@ -184,7 +180,7 @@ export default class SharedVideoManager {
184 180
 
185 181
         if (attributes.state == 'playing') {
186 182
 
187
-            this.processTime(player, attributes);
183
+            this.processTime(player, attributes, playerPaused);
188 184
 
189 185
             // lets check the volume
190 186
             if (attributes.volume !== undefined &&
@@ -200,7 +196,9 @@ export default class SharedVideoManager {
200 196
             // if its not paused, pause it
201 197
             player.pauseVideo();
202 198
 
203
-            this.processTime(player, attributes);
199
+            this.processTime(player, attributes, !playerPaused);
200
+        } else if (attributes.state == 'stop') {
201
+            this.stopSharedVideo(this.from);
204 202
         }
205 203
     }
206 204
 
@@ -208,9 +206,15 @@ export default class SharedVideoManager {
208 206
      * Check for time in attributes and if needed seek in current player
209 207
      * @param player the player to operate over
210 208
      * @param attributes the attributes with the player state we want
209
+     * @param forceSeek whether seek should be forced
211 210
      */
212
-    processTime (player, attributes)
211
+    processTime (player, attributes, forceSeek)
213 212
     {
213
+        if(forceSeek) {
214
+            player.seekTo(attributes.time);
215
+            return;
216
+        }
217
+
214 218
         // check received time and current time
215 219
         let currentPosition = player.getCurrentTime();
216 220
         let diff = Math.abs(attributes.time - currentPosition);
@@ -230,8 +234,10 @@ export default class SharedVideoManager {
230 234
     updateCheck(sendPauseEvent)
231 235
     {
232 236
         // ignore update checks if we are not the owner of the video
233
-        // or there is still no player defined
234
-        if(!APP.conference.isLocalId(this.from) || !this.player)
237
+        // or there is still no player defined or we are stopped
238
+        // (in a process of stopping)
239
+        if(!APP.conference.isLocalId(this.from) || !this.player
240
+            || !this.isSharedVideoShown)
235 241
             return;
236 242
 
237 243
         let state = this.player.getPlayerState();
@@ -281,13 +287,22 @@ export default class SharedVideoManager {
281 287
      * left and we want to remove video if the user sharing it left).
282 288
      * @param id the id of the sender of the command
283 289
      */
284
-    stopSharedVideo (id) {
290
+    stopSharedVideo (id, attributes) {
285 291
         if (!this.isSharedVideoShown)
286 292
             return;
287 293
 
288 294
         if(this.from !== id)
289 295
             return;
290 296
 
297
+        if(!this.player){
298
+            // if there is no error in the player till now,
299
+            // store the initial attributes
300
+            if (!this.errorInPlayer) {
301
+                this.initialAttributes = attributes;
302
+                return;
303
+            }
304
+        }
305
+
291 306
         if(this.intervalId) {
292 307
             clearInterval(this.intervalId);
293 308
             this.intervalId = null;
@@ -300,12 +315,19 @@ export default class SharedVideoManager {
300 315
                 VideoLayout.removeLargeVideoContainer(
301 316
                     SHARED_VIDEO_CONTAINER_TYPE);
302 317
 
303
-                this.player.destroy();
304
-                this.player = null;
318
+                if(this.player) {
319
+                    this.player.destroy();
320
+                    this.player = null;
321
+                }//
322
+                else if (this.errorInPlayer) {
323
+                    this.errorInPlayer.destroy();
324
+                    this.errorInPlayer = null;
325
+                }
305 326
         });
306 327
 
307 328
         this.url = null;
308 329
         this.isSharedVideoShown = false;
330
+        this.initialAttributes = null;
309 331
     }
310 332
 }
311 333
 

Laddar…
Avbryt
Spara