Browse Source

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

Shared video updates
master
yanas 9 years ago
parent
commit
b7cc03df26
5 changed files with 46 additions and 24 deletions
  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 View File

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

+ 1
- 1
index.html View File

126
                         <span id="unreadMessages"></span>
126
                         <span id="unreadMessages"></span>
127
                     </a>
127
                     </a>
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>
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
                     <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>
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
                     <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>
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
                     <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>
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 View File

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

+ 1
- 1
modules/UI/UI.js View File

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

+ 42
- 20
modules/UI/shared_video/SharedVideo.js View File

44
 
44
 
45
         if(APP.conference.isLocalId(this.from)) {
45
         if(APP.conference.isLocalId(this.from)) {
46
             showStopVideoPropmpt().then(() =>
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
         } else {
49
         } else {
49
             messageHandler.openMessageDialog(
50
             messageHandler.openMessageDialog(
50
                 "dialog.shareVideoTitle",
51
                 "dialog.shareVideoTitle",
64
         if (this.isSharedVideoShown)
65
         if (this.isSharedVideoShown)
65
             return;
66
             return;
66
 
67
 
68
+        this.isSharedVideoShown = true;
69
+
67
         // the video url
70
         // the video url
68
         this.url = url;
71
         this.url = url;
69
 
72
 
82
         // we need to operate with player after start playing
85
         // we need to operate with player after start playing
83
         // self.player will be defined once it start playing
86
         // self.player will be defined once it start playing
84
         // and will process any initial attributes if any
87
         // and will process any initial attributes if any
85
-        this.initialAttributes = null;
88
+        this.initialAttributes = attributes;
86
 
89
 
87
         var self = this;
90
         var self = this;
88
         if(self.isPlayerAPILoaded)
91
         if(self.isPlayerAPILoaded)
148
                 SHARED_VIDEO_CONTAINER_TYPE, self.sharedVideo);
151
                 SHARED_VIDEO_CONTAINER_TYPE, self.sharedVideo);
149
             VideoLayout.handleVideoThumbClicked(self.url);
152
             VideoLayout.handleVideoThumbClicked(self.url);
150
 
153
 
151
-            self.isSharedVideoShown = true;
152
-
153
             // If we are sending the command and we are starting the player
154
             // If we are sending the command and we are starting the player
154
             // we need to continuously send the player current time position
155
             // we need to continuously send the player current time position
155
             if(APP.conference.isLocalId(self.from)) {
156
             if(APP.conference.isLocalId(self.from)) {
157
                     self.updateCheck.bind(self),
158
                     self.updateCheck.bind(self),
158
                     updateInterval);
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
         window.onPlayerError = function(event) {
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
 
180
 
185
         if (attributes.state == 'playing') {
181
         if (attributes.state == 'playing') {
186
 
182
 
187
-            this.processTime(player, attributes);
183
+            this.processTime(player, attributes, playerPaused);
188
 
184
 
189
             // lets check the volume
185
             // lets check the volume
190
             if (attributes.volume !== undefined &&
186
             if (attributes.volume !== undefined &&
200
             // if its not paused, pause it
196
             // if its not paused, pause it
201
             player.pauseVideo();
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
      * Check for time in attributes and if needed seek in current player
206
      * Check for time in attributes and if needed seek in current player
209
      * @param player the player to operate over
207
      * @param player the player to operate over
210
      * @param attributes the attributes with the player state we want
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
         // check received time and current time
218
         // check received time and current time
215
         let currentPosition = player.getCurrentTime();
219
         let currentPosition = player.getCurrentTime();
216
         let diff = Math.abs(attributes.time - currentPosition);
220
         let diff = Math.abs(attributes.time - currentPosition);
230
     updateCheck(sendPauseEvent)
234
     updateCheck(sendPauseEvent)
231
     {
235
     {
232
         // ignore update checks if we are not the owner of the video
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
             return;
241
             return;
236
 
242
 
237
         let state = this.player.getPlayerState();
243
         let state = this.player.getPlayerState();
281
      * left and we want to remove video if the user sharing it left).
287
      * left and we want to remove video if the user sharing it left).
282
      * @param id the id of the sender of the command
288
      * @param id the id of the sender of the command
283
      */
289
      */
284
-    stopSharedVideo (id) {
290
+    stopSharedVideo (id, attributes) {
285
         if (!this.isSharedVideoShown)
291
         if (!this.isSharedVideoShown)
286
             return;
292
             return;
287
 
293
 
288
         if(this.from !== id)
294
         if(this.from !== id)
289
             return;
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
         if(this.intervalId) {
306
         if(this.intervalId) {
292
             clearInterval(this.intervalId);
307
             clearInterval(this.intervalId);
293
             this.intervalId = null;
308
             this.intervalId = null;
300
                 VideoLayout.removeLargeVideoContainer(
315
                 VideoLayout.removeLargeVideoContainer(
301
                     SHARED_VIDEO_CONTAINER_TYPE);
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
         this.url = null;
328
         this.url = null;
308
         this.isSharedVideoShown = false;
329
         this.isSharedVideoShown = false;
330
+        this.initialAttributes = null;
309
     }
331
     }
310
 }
332
 }
311
 
333
 

Loading…
Cancel
Save