front_idill/src/mosaic/js/playerControl.js
author bastiena
Fri, 21 Sep 2012 16:12:59 +0200
changeset 109 ace8f4b644f1
parent 79 9eff85166868
permissions -rw-r--r--
Front IDILL: help details shown text usage repaired
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     1
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     3
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     5
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     7
* file that was distributed with this source code.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     8
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     9
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    10
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    11
 * Projet : TraKERS
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    12
 * Module : Front IDILL
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    13
 * Fichier : playerControl.js
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    14
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    16
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    17
 * Fonctionnalités : Définit les fonctions d'interaction avec le player dans la mosaique.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    18
 */
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    19
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    20
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    21
 * Passe à une vidéo suivante pour la lire, peut passer d'une vidéo à une autre en cas de filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    22
 * Est appelé : dans le fichier mosaic > fonctions manageControlEvents et onPlayerLoad.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    23
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    24
Mosaic.prototype.playNextVideo = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    25
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    26
    //Définit l'id du snapshot principal et le suivant à lire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    27
    var videoId = this.centerId, nextId = (+videoId + 1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    28
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    29
    //Si on arrive à la fin de la mosaique on revient au début.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    30
    if(videoId >= this.config.imagesToShow - 1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    31
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    32
        nextId = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    33
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    34
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    35
    //Si la mosaique est filtrée, on passe directement à la prochaine vidéo non filtrée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    36
    if(this.isMosaicFiltered)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    37
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    38
        //Tant que la vidéo est masquée par un filtre de recherche, on passe à la vidéo suivante.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    39
        while(this.opacities[nextId] == 0 && nextId < this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    40
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    41
            nextId++;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    42
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    43
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    44
        //Si on arrive à la fin on revient au début.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    45
        if(nextId == this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    46
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    47
            nextId = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    48
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    49
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    50
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    51
    //On se déplace vers la prochaine vidéo à lire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    52
    this.autoMove = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    53
    this.moveToNeighbour($('#snapshotDiv-' + nextId));
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    54
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    55
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    56
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    57
 * Indique si la timeline est sélectionnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    58
 * Est appelé : dans le fichier pointers > fonctions mainPointerDisplay et pointersTimelineSelection.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    59
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    60
Mosaic.prototype.isTLSelected = function(entering, mainPointer)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    61
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    62
    //Si les deux pointeurs ne sont pas là ou qu'on n'est pas en lecture d'une vidéo.
79
9eff85166868 Front IDILL :
bastiena
parents: 52
diff changeset
    63
    if(this.isMainPointerDisplayed && this.isSecondPointerDisplayed || this.currentMode != 'VIDEO' && this.currentMode != 'SEARCH' && this.currentMode != 'TIMELINE' || !this.playerIsReady || this.isSearchByCurvesOn)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    64
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    65
        return false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    66
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    67
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    68
    var pointer;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    69
    var Px, Py;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    70
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    71
    //Si on est en mode d'interaction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    72
    if(this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    73
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    74
        //On met à jour la position estimée de la souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    75
        Px = this.mousePosX;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    76
        Py = this.mousePosY;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    77
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    78
    else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    79
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    80
        //Sinon on se fie à la position des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    81
        pointer = (mainPointer ? $('#mainPointer') : $('#secondPointer'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    82
        Px = pointer.position().left + pointer.width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    83
        Py = pointer.position().top + pointer.height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    84
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    85
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    86
    //Si le pointeur se situe sur la timeline, on renvoie vrai, sinon faux.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    87
    var TL = $('.Ldt-Timeline');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    88
    var TLwidth = TL.width(), TLheight = TL.height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    89
    var TLtop = (+$('.LdtPlayer').position().top + $('.LdtPlayer').height() - TLheight), TLleft = $('.LdtPlayer').position().left;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    90
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    91
    var correctHorizontalPosition = (entering ? (Px > TLleft && Px < (+TLleft + TLwidth)) : (true));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    92
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    93
    if(correctHorizontalPosition && Py > (TLtop - TLheight / 2) && Py < (+TLtop + TLheight))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    94
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    95
        return true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    96
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    97
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    98
    return false;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    99
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   100
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   101
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   102
 * Sert à déselectionner la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   103
 * Est appelé : dans les fichiers neighbours > fonction moveToNeighbour, pointers > fonctions mainPointerDisplay, secondPointerDisplay et pointersTimelineSelection et zoomInteractions > fonction unzoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   104
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   105
Mosaic.prototype.exitTimeline = function(typeOfInteraction)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   106
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   107
    //Si on est en mode timeline et que le player est prêt.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   108
    if(this.currentMode == 'TIMELINE' && this.playerIsReady)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   109
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   110
        //On enlève les notifications.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   111
        this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   112
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   113
        //On remet à zéro les variables concernées.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   114
        this.isTLRequested = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   115
        this.canSlideInTL = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   116
        //On déselectionne la timeline au niveau du player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   117
        this.player.widgets[0].deselectTimeline();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   118
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   119
        if($('#spinner').length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   120
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   121
            $('#spinner').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   122
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   123
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   124
        //On remet l'apparence des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   125
        if(this.isTLSelectedByMainPointer)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   126
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   127
            $('#mainPointer').css('background-image', 'url(./img/cursors/pointer.png)');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   128
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   129
        if(this.isTLSelectedBySecondPointer)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   130
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   131
            $('#secondPointer').css('background-image', 'url(./img/cursors/pointer2.png)');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   132
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   133
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   134
        this.isTLSelectedByMainPointer = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   135
        this.isTLSelectedBySecondPointer = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   136
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   137
        //On revient dans le mode précédent, en fonction de l'action effectuée pour quitter la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   138
        //Si l'action était juste de mettre le pointeur hors de la timeline, on revient en mode video/search en fonction de l'existence d'une gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   139
        if(typeOfInteraction == 'unzoom')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   140
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   141
            if(this.isMosaicFiltered)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   142
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   143
                this.currentMode = 'FILTER';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   144
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   145
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   146
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   147
                this.currentMode = 'MOSAIC';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   148
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   149
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   150
        else if(typeOfInteraction == 'move')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   151
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   152
            this.currentMode = 'VIDEO';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   153
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   154
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   155
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   156
            if(this.isCurrentlyInASearchByGesture)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   157
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   158
                this.currentMode = 'SEARCH';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   159
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   160
                this.searchGesture(this.currentSearchGesture[this.centerId], 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   161
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   162
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   163
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   164
                this.currentMode = 'VIDEO';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   165
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   166
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   167
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   168
}