src/js/widgets/playerWidget.js
author veltr
Tue, 17 Apr 2012 20:19:46 +0200
branchnew-model
changeset 868 a525cc2214e7
parent 842 4ae2247a59f4
child 870 2c025db10a10
permissions -rw-r--r--
Started big refactoring
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
838
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     1
/* Internationalization for this widget */
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     2
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     3
IriSP.i18n.addMessages(
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     4
    {
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     5
        "en": {
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     6
            "play_pause": "Play/Pause",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     7
            "mute_unmute": "Mute/Unmute",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     8
            "play": "Play",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
     9
            "pause": "Pause",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    10
            "mute": "Mute",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    11
            "unmute": "Unmute",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    12
            "annotate": "Annotate",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    13
            "search": "Search",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    14
            "elapsed_time": "Elapsed time",
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    15
            "total_time": "Total time",
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    16
            "volume": "Volume",
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    17
            "volume_control": "Volume control"
838
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    18
        },
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    19
        "fr": {
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    20
            "play_pause": "Lecture/Pause",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    21
            "mute_unmute": "Couper/Activer le son",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    22
            "play": "Lecture",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    23
            "pause": "Pause",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    24
            "mute": "Couper le son",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    25
            "unmute": "Activer le son",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    26
            "annotate": "Annoter",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    27
            "search": "Rechercher",
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    28
            "elapsed_time": "Durée écoulée",
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    29
            "total_time": "Durée totale",
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    30
            "volume": "Niveau sonore",
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    31
            "volume_control": "Réglage du niveau sonore"
838
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    32
        }
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    33
    }
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    34
);
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    35
03b03865eb9b Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents: 837
diff changeset
    36
109
be17a396d68b fix to the PlayerWidget constructor.
hamidouk
parents: 98
diff changeset
    37
IriSP.PlayerWidget = function(Popcorn, config, Serializer) {
be17a396d68b fix to the PlayerWidget constructor.
hamidouk
parents: 98
diff changeset
    38
  IriSP.Widget.call(this, Popcorn, config, Serializer);
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
    39
  
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
    40
  this._searchBlockOpen = false;
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
    41
  this._searchLastValue = "";
109
be17a396d68b fix to the PlayerWidget constructor.
hamidouk
parents: 98
diff changeset
    42
};
115
464e3e892915 forgot an inheritance line.
hamidouk
parents: 109
diff changeset
    43
464e3e892915 forgot an inheritance line.
hamidouk
parents: 109
diff changeset
    44
IriSP.PlayerWidget.prototype = new IriSP.Widget();
464e3e892915 forgot an inheritance line.
hamidouk
parents: 109
diff changeset
    45
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    46
IriSP.PlayerWidget.prototype.draw = function() {
153
43f6de365ed4 general code cleanup.
hamidouk
parents: 151
diff changeset
    47
  var self = this;
131
44c1170e0044 renames.
hamidouk
parents: 121
diff changeset
    48
  var width = this.width;
44c1170e0044 renames.
hamidouk
parents: 121
diff changeset
    49
	var height = this.height;
44c1170e0044 renames.
hamidouk
parents: 121
diff changeset
    50
	var heightS = this.height-20;
261
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
    51
	  
831
0dd21c298380 Integration pour cinecast
veltr
parents: 830
diff changeset
    52
	var playerTempl = IriSP.templToHTML(IriSP.player_template, this._config);
564
a560a162f444 changed the position of the search textfield.
hamidouk
parents: 559
diff changeset
    53
  this.selector.append(playerTempl);		
468
651528a4f795 fixed a couple layout bugs that didn't appear in integration testing.
hamidouk
parents: 458
diff changeset
    54
	
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    55
  this.selector.children(".Ldt-controler").show();
153
43f6de365ed4 general code cleanup.
hamidouk
parents: 151
diff changeset
    56
    
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    57
  // handle clicks by the user on the video.
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    58
  this._Popcorn.listen("play", IriSP.wrap(this, this.playButtonUpdater));
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    59
  this._Popcorn.listen("pause", IriSP.wrap(this, this.playButtonUpdater));
449
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
    60
  
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    61
  this._Popcorn.listen("volumechange", IriSP.wrap(this, this.volumeUpdater));
440
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
    62
559
04e73ddebfa7 the total media duration now displays itself correctly at startup.
hamidouk
parents: 540
diff changeset
    63
  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.timeDisplayUpdater));  
04e73ddebfa7 the total media duration now displays itself correctly at startup.
hamidouk
parents: 540
diff changeset
    64
  // update the time display for the first time.
04e73ddebfa7 the total media duration now displays itself correctly at startup.
hamidouk
parents: 540
diff changeset
    65
  this._Popcorn.listen("loadedmetadata", IriSP.wrap(this, this.timeDisplayUpdater));
04e73ddebfa7 the total media duration now displays itself correctly at startup.
hamidouk
parents: 540
diff changeset
    66
  
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
    67
  this._Popcorn.listen("IriSP.search.matchFound", IriSP.wrap(this, this.searchMatch));
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
    68
  this._Popcorn.listen("IriSP.search.noMatchFound", IriSP.wrap(this, this.searchNoMatch));
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
    69
  this._Popcorn.listen("IriSP.search.triggeredSearch", IriSP.wrap(this, this.triggeredSearch));
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    70
  
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    71
  
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    72
  this.selector.find(".Ldt-CtrlPlay").click(function() { self.playHandler.call(self); });
540
b1f3aee23199 send a signal when receiving a click on the Annotate button.
hamidouk
parents: 468
diff changeset
    73
  this.selector.find(".Ldt-CtrlAnnotate").click(function() 
b1f3aee23199 send a signal when receiving a click on the Annotate button.
hamidouk
parents: 468
diff changeset
    74
                                            { self._Popcorn.trigger("IriSP.PlayerWidget.AnnotateButton.clicked"); });
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    75
  this.selector.find(".Ldt-CtrlSearch").click(function() { self.searchButtonHandler.call(self); });
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    76
  
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    77
	var _volctrl = this.selector.find(".Ldt-Ctrl-Volume-Control");
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    78
    this.selector.find('.Ldt-CtrlSound')
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    79
        .click(function() { self.muteHandler.call(self); } )
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    80
        .mouseover(function() {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    81
            _volctrl.show();
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    82
        })
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    83
        .mouseout(function() {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    84
            _volctrl.hide();
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    85
        });
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    86
    _volctrl.mouseover(function() {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    87
        _volctrl.show();
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    88
    }).mouseout(function() {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    89
        _volctrl.hide();
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
    90
    });
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    91
  
564
a560a162f444 changed the position of the search textfield.
hamidouk
parents: 559
diff changeset
    92
  /*
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    93
  var searchButtonPos = this.selector.find(".Ldt-CtrlSearch").position();
261
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
    94
  var searchBox = Mustache.to_html(IriSP.search_template, {margin_left : searchButtonPos.left + "px"});
564
a560a162f444 changed the position of the search textfield.
hamidouk
parents: 559
diff changeset
    95
  this.selector.find(".Ldt-CtrlSearch").after(searchBox);
a560a162f444 changed the position of the search textfield.
hamidouk
parents: 559
diff changeset
    96
  */
261
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
    97
  
331
ef3447aa6920 player widget now sends a special message when the mouse is hovering it.
hamidouk
parents: 311
diff changeset
    98
  // trigger an IriSP.PlayerWidget.MouseOver to the widgets that are interested (i.e : sliderWidget)
ef3447aa6920 player widget now sends a special message when the mouse is hovering it.
hamidouk
parents: 311
diff changeset
    99
  this.selector.hover(function() { self._Popcorn.trigger("IriSP.PlayerWidget.MouseOver"); }, 
ef3447aa6920 player widget now sends a special message when the mouse is hovering it.
hamidouk
parents: 311
diff changeset
   100
                      function() { self._Popcorn.trigger("IriSP.PlayerWidget.MouseOut"); });
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   101
  this.selector.find(".Ldt-Ctrl-Volume-Cursor").draggable({
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   102
      axis: "x",
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   103
      drag: function(event, ui) {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   104
          var _vol = Math.max(0, Math.min( 1, ui.position.left / (ui.helper.parent().width() - ui.helper.outerWidth())));
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   105
          ui.helper.attr("title",IriSP.i18n.getMessage('volume')+': ' + Math.floor(100*_vol) + '%');
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   106
          self._Popcorn.volume(_vol);
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   107
      },
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   108
      containment: "parent"
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   109
  });
458
5bafddd9e3ba fixed button display bug.
hamidouk
parents: 449
diff changeset
   110
 
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   111
 setTimeout(function() {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   112
     self.volumeUpdater();
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   113
 }, 1000); /* some player - jwplayer notable - save the state of the mute button between sessions */
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   114
};
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   115
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   116
/* Update the elasped time div */
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   117
IriSP.PlayerWidget.prototype.timeDisplayUpdater = function() {
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   118
  
830
18ca612e9ff0 Lots of changes
veltr
parents: 820
diff changeset
   119
  if (this._previousSecond === undefined) {
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   120
    this._previousSecond = this._Popcorn.roundTime();
830
18ca612e9ff0 Lots of changes
veltr
parents: 820
diff changeset
   121
  }
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   122
  else {
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   123
    /* we're still in the same second, so it's not necessary to update time */
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   124
    if (this._Popcorn.roundTime() == this._previousSecond)
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   125
      return;
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   126
      
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   127
  }
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   128
  
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   129
  // we get it at each call because it may change.
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 839
diff changeset
   130
  var duration = this.getDuration() / 1000; 
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   131
  var totalTime = IriSP.secondsToTime(duration);
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   132
  var elapsedTime = IriSP.secondsToTime(this._Popcorn.currentTime());
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   133
  
338
3ff4499f79bb WIP - graphical integration.
hamidouk
parents: 331
diff changeset
   134
  this.selector.find(".Ldt-ElapsedTime").html(elapsedTime.toString());
3ff4499f79bb WIP - graphical integration.
hamidouk
parents: 331
diff changeset
   135
  this.selector.find(".Ldt-TotalTime").html(totalTime.toString());
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
   136
  this._previousSecond = this._Popcorn.roundTime();
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   137
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   138
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   139
/* update the icon of the button - separate function from playHandler
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   140
   because in some cases (for instance, when the user directly clicks on
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   141
   the jwplayer window) we have to change the icon without playing/pausing
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   142
*/
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   143
IriSP.PlayerWidget.prototype.playButtonUpdater = function() {
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   144
  var status = this._Popcorn.media.paused;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   145
  
802
c74de6ba5d11 fixed player buttons. They now use css class instead of directly refering to the
hamidouk
parents: 732
diff changeset
   146
  if ( status == true ){
c74de6ba5d11 fixed player buttons. They now use css class instead of directly refering to the
hamidouk
parents: 732
diff changeset
   147
    /* the background sprite is changed by adding/removing the correct classes */
837
353a78021ebc Added Internationalization
veltr
parents: 831
diff changeset
   148
    this.selector.find(".Ldt-CtrlPlay").attr("title", IriSP.i18n.getMessage('play'));
802
c74de6ba5d11 fixed player buttons. They now use css class instead of directly refering to the
hamidouk
parents: 732
diff changeset
   149
    this.selector.find(".Ldt-CtrlPlay").removeClass("Ldt-CtrlPlay-PauseState").addClass("Ldt-CtrlPlay-PlayState");
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   150
  } else {
837
353a78021ebc Added Internationalization
veltr
parents: 831
diff changeset
   151
    this.selector.find(".Ldt-CtrlPlay").attr("title", IriSP.i18n.getMessage('pause'));
802
c74de6ba5d11 fixed player buttons. They now use css class instead of directly refering to the
hamidouk
parents: 732
diff changeset
   152
    this.selector.find(".Ldt-CtrlPlay").removeClass("Ldt-CtrlPlay-PlayState").addClass("Ldt-CtrlPlay-PauseState");
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   153
  }  
440
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
   154
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
   155
  return;
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   156
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   157
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   158
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   159
IriSP.PlayerWidget.prototype.playHandler = function() {
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   160
  var status = this._Popcorn.media.paused;
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   161
  
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   162
  if ( status == true ){        
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   163
    this._Popcorn.play();   
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   164
  } else {
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   165
    this._Popcorn.pause();
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   166
  }  
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   167
};
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   168
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   169
IriSP.PlayerWidget.prototype.muteHandler = function() {
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   170
  this._Popcorn.mute(!this._Popcorn.muted());
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   171
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   172
839
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   173
IriSP.PlayerWidget.prototype.volumeUpdater = function() {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   174
    var _muted = this._Popcorn.muted(),
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   175
        _vol = this._Popcorn.volume();
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   176
    if (_vol === false) {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   177
        _vol = .5;
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   178
    }
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   179
    var _soundCtl = this.selector.find(".Ldt-CtrlSound");
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   180
    _soundCtl.removeClass("Ldt-CtrlSound-Mute Ldt-CtrlSound-Half Ldt-CtrlSound-Full");
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   181
    if (_muted) {        
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   182
        _soundCtl.attr("title", IriSP.i18n.getMessage('unmute'))
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   183
            .addClass("Ldt-CtrlSound-Mute");    
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   184
    } else {
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   185
        _soundCtl.attr("title", IriSP.i18n.getMessage('mute'))
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   186
            .addClass(_vol < .5 ? "Ldt-CtrlSound-Half" : "Ldt-CtrlSound-Full" )
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   187
    }
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   188
    var _cursor = this.selector.find(".Ldt-Ctrl-Volume-Cursor");
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   189
    _cursor.css({
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   190
        "left": ( _muted ? 0 : Math.floor(_vol * (_cursor.parent().width() - _cursor.outerWidth())) ) + "px"
4357aac4eb19 Added volume support
veltr
parents: 838
diff changeset
   191
    })
449
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   192
};
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   193
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   194
IriSP.PlayerWidget.prototype.showSearchBlock = function() {
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   195
  var self = this;
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   196
  
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   197
  if (this._searchBlockOpen == false) {
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   198
    this.selector.find(".LdtSearch").show("blind", { direction: "horizontal"}, 100);
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   199
    this.selector.find(".LdtSearchInput").css('background-color','#fff');
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   200
   
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   201
    this._searchBlockOpen = true;           
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   202
    this.selector.find(".LdtSearchInput").bind('keyup', null, function() { self.searchHandler.call(self); } );
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   203
    this.selector.find(".LdtSearchInput").focus();
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   204
    
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   205
    // we need this variable because some widget can find a match in
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   206
    // their data while at the same time other's don't. As we want the
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   207
    // search field to become green when there's a match, we need a 
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   208
    // variable to remember that we had one.
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   209
    this._positiveMatch = false;
449
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   210
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   211
    // tell the world the field is open
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   212
    this._Popcorn.trigger("IriSP.search.open");     
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   213
	}
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   214
};
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   215
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   216
IriSP.PlayerWidget.prototype.hideSearchBlock = function() {
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   217
 if (this._searchBlockOpen == true) {
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   218
    this._searchLastValue = this.selector.find(".LdtSearchInput").attr('value');
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   219
    this.selector.find(".LdtSearchInput").attr('value','');
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   220
    this.selector.find(".LdtSearch").hide("blind", { direction: "horizontal"}, 75);
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   221
    
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   222
    // unbind the watcher event.
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   223
    this.selector.find(".LdtSearchInput").unbind('keypress set');
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   224
    this._searchBlockOpen = false;
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   225
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   226
    this._positiveMatch = false;
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   227
    
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   228
    this._Popcorn.trigger("IriSP.search.closed");
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   229
	}
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   230
};
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   231
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   232
/** react to clicks on the search button */
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   233
IriSP.PlayerWidget.prototype.searchButtonHandler = function() {
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   234
  var self = this;
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   235
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   236
  /* show the search field if it is not shown */
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   237
  if ( this._searchBlockOpen == false ) {
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   238
    this.showSearchBlock();
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   239
    this.selector.find(".LdtSearchInput").attr('value', this._searchLastValue);      
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   240
    this._Popcorn.trigger("IriSP.search", this._searchLastValue); // trigger the search to make it more natural.
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   241
	} else {
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   242
    this.hideSearchBlock();
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   243
  }
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   244
};
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   245
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   246
/** this handler is called whenever the content of the search
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   247
   field changes */
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   248
IriSP.PlayerWidget.prototype.searchHandler = function() {
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   249
  this._searchLastValue = this.selector.find(".LdtSearchInput").attr('value');
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   250
  this._positiveMatch = false;
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   251
  
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   252
  // do nothing if the search field is empty, instead of highlighting everything.
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   253
  if (this._searchLastValue == "") {
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   254
    this._Popcorn.trigger("IriSP.search.cleared");
355
d8df77c40676 fixed search field coloring.
hamidouk
parents: 338
diff changeset
   255
    this.selector.find(".LdtSearchInput").css('background-color','');
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   256
  } else {
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   257
    this._Popcorn.trigger("IriSP.search", this._searchLastValue);
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   258
  }
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   259
};
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   260
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   261
/**
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   262
  handler for the IriSP.search.found message, which is sent by some views when they
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   263
  highlight a match.
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   264
*/
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   265
IriSP.PlayerWidget.prototype.searchMatch = function() {
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   266
  this._positiveMatch = true;
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   267
  this.selector.find(".LdtSearchInput").css('background-color','#e1ffe1');
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   268
};
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   269
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   270
/** the same, except that no value could be found */
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   271
IriSP.PlayerWidget.prototype.searchNoMatch = function() {
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   272
  if (this._positiveMatch !== true)
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   273
    this.selector.find(".LdtSearchInput").css('background-color', "#d62e3a");
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   274
};
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   275
732
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   276
/** react to an IriSP.Player.triggeredSearch - that is, when
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   277
    a widget ask the PlayerWidget to do a search on his behalf */
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   278
IriSP.PlayerWidget.prototype.triggeredSearch = function(searchString) {
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   279
  this.showSearchBlock();
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   280
  this.selector.find(".LdtSearchInput").attr('value', searchString);      
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   281
  this._Popcorn.trigger("IriSP.search", searchString); // trigger the search to make it more natural.
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   282
};
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   283
823fa16807d4 refactored the code to allow external widget to do searches.
hamidouk
parents: 659
diff changeset
   284