src/widgets/MashupPlayer.js
changeset 983 97fef7a4b189
parent 970 b1c3bf6eca78
child 1013 392ddcd212d7
equal deleted inserted replaced
982:cfcbac34d020 983:97fef7a4b189
    22         _segmentBegin,
    22         _segmentBegin,
    23         _segmentEnd,
    23         _segmentEnd,
    24         _timecode = 0,
    24         _timecode = 0,
    25         _seeking = false,
    25         _seeking = false,
    26         _seekdiv,
    26         _seekdiv,
    27         _timedelta;
    27         _timedelta,
       
    28         medialist = _mashup.getMedias();
    28     
    29     
    29     _mashup.paused = (!this.autostart && !this.autoplay)
    30     _mashup.paused = (!this.autostart && !this.autoplay)
    30     
    31     
    31     function changeCurrentAnnotation() {
    32     function changeCurrentAnnotation() {
    32         if (_timecode >= _mashup.duration) {
    33         if (_timecode >= _mashup.duration) {
    52             _segmentBegin = _currentAnnotation.annotation.begin.milliseconds;
    53             _segmentBegin = _currentAnnotation.annotation.begin.milliseconds;
    53             _segmentEnd = _currentAnnotation.annotation.end.milliseconds;
    54             _segmentEnd = _currentAnnotation.annotation.end.milliseconds;
    54             _timedelta = _segmentBegin - _currentAnnotation.begin.milliseconds;
    55             _timedelta = _segmentBegin - _currentAnnotation.begin.milliseconds;
    55             _currentMedia = _currentAnnotation.getMedia();
    56             _currentMedia = _currentAnnotation.getMedia();
    56             
    57             
    57             for (var _i = 0; _i < _mashup.medias.length; _i++) {
    58             for (var _i = 0; _i < medialist.length; _i++) {
    58                 if (_mashup.medias[_i].id !== _currentMedia.id) {
    59                 if (medialist[_i].id !== _currentMedia.id) {
    59                     if (!_this.split_screen) {
    60                     if (!_this.split_screen) {
    60                         _mashup.medias[_i].hide();
    61                         medialist[_i].hide();
    61                     }
    62                     }
    62                     _mashup.medias[_i].pause();
    63                     medialist[_i].pause();
    63                 } else {
    64                 } else {
    64                     _mashup.medias[_i].show();
    65                     medialist[_i].show();
    65                 }
    66                 }
    66             }
    67             }
    67             
    68             
    68     /* PRELOADING */
    69     /* PRELOADING */
    69             var _preloadedMedias = [],
    70             var _preloadedMedias = [],
   111     
   112     
   112     this.$.css({
   113     this.$.css({
   113         background: this.background
   114         background: this.background
   114     });
   115     });
   115     
   116     
   116     var _grid = Math.ceil(Math.sqrt(_mashup.medias.length)),
   117     var _grid = Math.ceil(Math.sqrt(medialist.length)),
   117         _width = (this.split_screen ? this.width / _grid : this.width),
   118         _width = (this.split_screen ? this.width / _grid : this.width),
   118         _height = (this.split_screen ? this.height / _grid : this.height)
   119         _height = (this.split_screen ? this.height / _grid : this.height);
   119 
   120 
   120     IriSP._(_mashup.medias).each(function(_media, _key) {
   121     IriSP._(medialist).each(function(_media, _key) {
   121         var _el = IriSP.jQuery('<div class="Ldt-MashupPlayer-Media"><div class="Ldt-MashupPlayer-Subwidget"></div></div>');
   122         var _el = IriSP.jQuery('<div class="Ldt-MashupPlayer-Media"><div class="Ldt-MashupPlayer-Subwidget"></div></div>');
   122         _el.css({
   123         _el.css({
   123             top: (_this.split_screen ? _height * Math.floor(_key / _grid) : 0),
   124             top: (_this.split_screen ? _height * Math.floor(_key / _grid) : 0),
   124             left: (_this.split_screen ? _width * (_key % _grid) : 0),
   125             left: (_this.split_screen ? _width * (_key % _grid) : 0),
   125             height: _height,
   126             height: _height,
   147             _el.hide();
   148             _el.hide();
   148         };
   149         };
   149         _media.on("loadedmetadata", function() {
   150         _media.on("loadedmetadata", function() {
   150             _media.loadedMetadata = true;
   151             _media.loadedMetadata = true;
   151             var _allLoaded = true;
   152             var _allLoaded = true;
   152             for (var _i = 0; _i < _mashup.medias.length; _i++) {
   153             for (var _i = 0; _i < medialist.length; _i++) {
   153                 _allLoaded = _allLoaded && _mashup.medias[_i].loadedMetadata;
   154                 _allLoaded = _allLoaded && medialist[_i].loadedMetadata;
   154             }
   155             }
   155             if (_allLoaded) {
   156             if (_allLoaded) {
   156                 _seekdiv.fadeOut();
   157                 _seekdiv.fadeOut();
   157                 changeCurrentAnnotation();
   158                 changeCurrentAnnotation();
   158                 _mashup.trigger("loadedmetadata");
   159                 _mashup.trigger("loadedmetadata");
   225         _timecode = _milliseconds;
   226         _timecode = _milliseconds;
   226         changeCurrentAnnotation();
   227         changeCurrentAnnotation();
   227     });
   228     });
   228     
   229     
   229     _mashup.on("setvolume", function(_vol) {
   230     _mashup.on("setvolume", function(_vol) {
   230         for (var _i = 0; _i < _mashup.medias.length; _i++) {
   231         for (var _i = 0; _i < medialist.length; _i++) {
   231             _mashup.medias[_i].setVolume(_vol);
   232             medialist[_i].setVolume(_vol);
   232         }
   233         }
   233         _mashup.volume = _vol;
   234         _mashup.volume = _vol;
   234     });
   235     });
   235     
   236     
   236     _mashup.on("setmuted", function(_muted) {
   237     _mashup.on("setmuted", function(_muted) {
   237         for (var _i = 0; _i < _mashup.medias.length; _i++) {
   238         for (var _i = 0; _i < medialist.length; _i++) {
   238             _mashup.medias[_i].setMuted(_muted);
   239             medialist[_i].setMuted(_muted);
   239         }
   240         }
   240         _mashup.muted = _muted;
   241         _mashup.muted = _muted;
   241     });
   242     });
   242     
   243     
   243     _mashup.on("setplay", function() {
   244     _mashup.on("setplay", function() {