Ignore:
Timestamp:
06/13/07 16:55:58 (5 years ago)
Author:
dar
Message:

Indentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/xAudioHier/Xul_Audio/chrome/content/audio-toolkit/audio.xml

    r9200 r9275  
    22   
    33 
    4 <bindings xmlns = "http://www.mozilla.org/xbl" 
    5         xmlns:xbl = "http://www.mozilla.org/xbl" 
    6         xmlns:html = "http://www.w3.org/1999/xhtml" 
    7         xmlns:xul = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
    8         xmlns:ec = "http://ircam.fr/ecoute" 
    9         xmlns:xlink="http://www.w3.org/1999/xlink" 
     4<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" 
     5        xmlns:html="http://www.w3.org/1999/xhtml" 
     6        xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
     7        xmlns:ec="http://ircam.fr/ecoute" xmlns:xlink="http://www.w3.org/1999/xlink" 
    108        xmlns:svg="http://www.w3.org/2000/svg"> 
    119 
    12 <binding id="audio" extends="svg:generic"> 
    13 <content> 
    14 <xul:vbox anonid="xulroot"> 
    15                                  
    16 <svg:svg width="550px" height="200px" viewBox="0 0 1100 400" anonid="svgbody" preserveAspectRatio="xMinYMin meet" opacity="0.3"> 
    17  
    18  
    19  
    20 <svg:subplayer anonid="mainplayer" leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" rightHandle="chrome://audio-toolkit/content/images/handleRight.png"/> 
    21 <svg:subplayer anonid="segplayer" selstyle="fill:       #cc9dfa; opacity: 0.7" transform="translate(0, 50)" leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" rightHandle="chrome://audio-toolkit/content/images/handleRight.png"/> 
    22 <svg:subplayer anonid="zoomplayer" selstyle="fill:      #f6e69d; opacity: 0.7" transform="translate(0, 100)" leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" rightHandle="chrome://audio-toolkit/content/images/handleRight.png"/> 
    23  
    24  
    25                                          
    26 <svg:g transform="translate(0, 140)" class="zoomarea"> 
    27 <svg:g anonid="plotbox"/> 
    28 <svg:line class="zmarker" anonid="zmarker1" x1="70" y1="0" x2="70" y2="50"/> 
    29 <svg:line class="zmarker" anonid="zmarker2" x1="925" y1="0" x2="995" y2="50"/> 
    30 <svg:rect anonid="ground" x="70" y="50" height="200" width="925" stroke="black"/> 
    31 <svg:svg anonid="zoomarea" x="70" y="50" height="200" width="925" viewBox="0 0 1000 100" preserveAspectRatio="none" overflow="hidden"> 
    32 <children/> 
    33 </svg:svg> 
    34 </svg:g> 
    35  
    36  
    37  
    38 <svg:svg x="1040" y="0" width="60" height="400" stroke="red" fill="red" class="svgtoolbar" viewBox="0 0 60 400" overflow="visible"> 
    39 <svg:g anonid="button_pitch" transform="translate(0, 0)"> 
    40 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" stroke="#444" rx="5" ry="5"/> 
    41 </svg:g> 
    42 <svg:g anonid="button_add" transform="translate(0, 50)"> 
    43 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" stroke="#444" rx="5" ry="5"/> 
    44 <svg:path d="M8,17 l18,0 M17,8 l0,18" stroke="#000" stroke-width="5"/> 
    45 </svg:g> 
    46 <svg:g anonid="button_zoom1" transform="translate(0, 100)"> 
    47 <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" stroke="#444" rx="5" ry="5"/> 
    48 <svg:path d="M10,8 l0,18 M17,12 l0,4 M17,17 l0,4 M24,8 l0,18" stroke="#000" stroke-width="4"/> 
    49 </svg:g> 
    50 </svg:svg> 
    51 <svg:rect anonid="disablelayer" x="0" y="0" height="100%" width="100%" opacity="0"/> 
    52 </svg:svg> 
    53 </xul:vbox> 
    54 </content> 
    55 <implementation> 
    56                          
    57 <constructor> 
    58 <![CDATA[ 
     10        <binding id="audio" extends="svg:generic"> 
     11                <content> 
     12                        <xul:vbox anonid="xulroot"> 
     13 
     14                                <svg:svg width="550px" height="200px" viewBox="0 0 1100 400" anonid="svgbody" 
     15                                        preserveAspectRatio="xMinYMin meet" opacity="0.3"> 
     16                                        <svg:subplayer anonid="mainplayer" 
     17                                                leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" 
     18                                                rightHandle="chrome://audio-toolkit/content/images/handleRight.png" /> 
     19                                        <svg:subplayer anonid="segplayer" selstyle="fill:       #cc9dfa; opacity: 0.7" 
     20                                                transform="translate(0, 50)" 
     21                                                leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" 
     22                                                rightHandle="chrome://audio-toolkit/content/images/handleRight.png" /> 
     23                                        <svg:subplayer anonid="zoomplayer" selstyle="fill:      #f6e69d; opacity: 0.7" 
     24                                                transform="translate(0, 100)" 
     25                                                leftHandle="chrome://audio-toolkit/content/images/handleLeft.png" 
     26                                                rightHandle="chrome://audio-toolkit/content/images/handleRight.png" /> 
     27                                        <svg:g transform="translate(0, 140)" class="zoomarea"> 
     28                                                <svg:g anonid="plotbox" /> 
     29                                                <svg:line class="zmarker" anonid="zmarker1" x1="70" y1="0" x2="70" y2="50" /> 
     30                                                <svg:line class="zmarker" anonid="zmarker2" x1="925" y1="0" x2="995" y2="50" /> 
     31                                                <svg:rect anonid="ground" x="70" y="50" height="200" width="925" stroke="black" /> 
     32                                                <svg:svg anonid="zoomarea" x="70" y="50" height="200" width="925" viewBox="0 0 1000 100" 
     33                                                        preserveAspectRatio="none" overflow="hidden"> 
     34                                                        <children /> 
     35                                                </svg:svg> 
     36                                        </svg:g> 
     37                                        <svg:svg x="1040" y="0" width="60" height="400" stroke="red" fill="red" class="svgtoolbar" 
     38                                                viewBox="0 0 60 400" overflow="visible"> 
     39                                                <svg:g anonid="button_pitch" transform="translate(0, 0)"> 
     40                                                        <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" 
     41                                                                stroke="#444" rx="5" ry="5" /> 
     42                                                </svg:g> 
     43                                                <svg:g anonid="button_add" transform="translate(0, 50)"> 
     44                                                        <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" 
     45                                                                stroke="#444" rx="5" ry="5" /> 
     46                                                        <svg:path d="M8,17 l18,0 M17,8 l0,18" stroke="#000" stroke-width="5" /> 
     47                                                </svg:g> 
     48                                                <svg:g anonid="button_zoom1" transform="translate(0, 100)"> 
     49                                                        <svg:rect x="0" y="0" height="34" width="34" fill="#aaa;" stroke-width="4" 
     50                                                                stroke="#444" rx="5" ry="5" /> 
     51                                                        <svg:path d="M10,8 l0,18 M17,12 l0,4 M17,17 l0,4 M24,8 l0,18" stroke="#000" 
     52                                                                stroke-width="4" /> 
     53                                                </svg:g> 
     54                                        </svg:svg> 
     55                                        <svg:rect anonid="disablelayer" x="0" y="0" height="100%" width="100%" opacity="0" /> 
     56                                </svg:svg> 
     57                        </xul:vbox> 
     58                </content> 
     59 
     60                <implementation> 
     61                        <constructor><![CDATA[ 
    5962                                this.statusEditor = 0; 
    6063 
     
    6871 
    6972                                this.updateZoom(0, 1000); 
    70  
    71  
    72                                 ]]> 
    73 </constructor> 
    74 <field name="playState"/> 
    75 <field name="statusEditor"/> 
    76 <property name="title"> 
    77 <setter> 
    78 <![CDATA[ 
    79                                                         this._title = val; 
    80                                                         this._mainplayer.setText("left", val); 
    81                                                 ]]> 
    82 </setter> 
    83 <getter> 
    84 <![CDATA[ 
    85                                                         return this._title; 
    86                                                 ]]> 
    87 </getter> 
    88 </property> 
    89 <property name="srcAudio"> 
    90 <getter> 
    91 <![CDATA[ 
    92                                                         return this._srcAudio; 
    93                                                 ]]> 
    94 </getter> 
    95 </property> 
    96                          
    97 <method name="zoomToSegment"> 
    98 <parameter name="aSegment"/> 
    99 <body> 
    100 <![CDATA[ 
    101                                                 if (!this.srcAudio) return; 
    102                                                 if( (this.statusEditor & 4) == 4) return; //en cours de batch, impossible car temps invalides 
    103          
    104                                                 var x1 = aSegment.start; 
    105                                                 var x2 = aSegment.end; 
    106                                                 var t1 = this._zoomplayer.t1; 
    107                                                 var t2 = this._zoomplayer.t2; 
    108                                                 if (x2 - x1 <= t2 - t1) { 
    109                                                         if (x2 <= t2 && x1 >= t1) { 
    110                                                                 return; 
    111                                                         } else { 
    112                                                                 this._zoomplayer.setT1(x1 - ((t2 - t1) - (x2 - x1)) / 2, true); 
    113                                                                 this._zoomplayer.setT2(this._zoomplayer.t1 + t2 - t1, true); 
    114                                                         } 
     73                        ]]></constructor> 
     74                        <field name="playState" /> 
     75                        <field name="statusEditor" /> 
     76                        <property name="title"> 
     77                                <setter><![CDATA[ 
     78                                        this._title = val; 
     79                                        this._mainplayer.setText("left", val); 
     80                                ]]></setter> 
     81                                <getter><![CDATA[ 
     82                                        return this._title; 
     83                                ]]></getter> 
     84                        </property> 
     85                        <property name="srcAudio"> 
     86                                <getter><![CDATA[ 
     87                                        return this._srcAudio; 
     88                                ]]></getter> 
     89                        </property> 
     90 
     91                        <method name="zoomToSegment"> 
     92                                <parameter name="aSegment" /> 
     93                                <body><![CDATA[ 
     94                                        if (!this.srcAudio) return; 
     95                                        if( (this.statusEditor & 4) == 4) return; //en cours de batch, impossible car temps invalides 
     96 
     97                                        var x1 = aSegment.start; 
     98                                        var x2 = aSegment.end; 
     99                                        var t1 = this._zoomplayer.t1; 
     100                                        var t2 = this._zoomplayer.t2; 
     101                                        if (x2 - x1 <= t2 - t1) { 
     102                                                if (x2 <= t2 && x1 >= t1) { 
     103                                                        return; 
    115104                                                } else { 
    116                                                         this._zoomplayer.setT1(x1 - (x2 - x1) / 2, true); 
    117                                                         this._zoomplayer.setT2(x2 + (x2 - x1) / 2, true); 
    118                                                 } 
    119                                         ]]> 
    120 </body> 
    121 </method> 
    122 <method name="setFocusOnSegment"> 
    123 <parameter name="aSegment"/> 
    124 <body> 
    125 <![CDATA[ 
    126                                                 if (!this.srcAudio) return; 
    127                                                 if (this.focusedSegment && !(aSegment === this.focusedSegment )) { 
    128                                                         this.focusedSegment.removeAttribute("checked"); 
    129                                                         if (this.focusedSegment.segmentOwner) { 
    130                                                                 this.focusedSegment.segmentOwner.segLooseFocus(this.focusedSegment); 
    131                                                         } 
    132                                                 } 
    133                                                 this.focusedSegment = aSegment; 
    134                                                 if( (this.statusEditor & 4) == 4) return; //en cours de batch, on recalculera tout ca plus tard.  
    135                                                 if (!aSegment) { 
    136                                                         this._segplayer.showZone(false); 
    137                                                         this._segplayer.setText("left", ""); 
    138                                                         this._segplayer.setText("right", ""); 
    139                                                 } else { 
    140                                                         this._segplayer.setText("left", aSegment.getAttribute("title")); 
    141                                                         this._segplayer.setText("right", 
    142                                                                 "(" + this.s2Str(aSegment.start * (this.duration / 1000), 0) + "-" + 
    143                                                                 this.s2Str((aSegment.end) * (this.duration / 1000), 0) + ") " + 
    144                                                                 this.s2Str((aSegment.end - aSegment.start) * (this.duration / 1000), 2)); 
    145                                                         aSegment.setAttribute("checked", "true"); 
    146                                                         this._segplayer.setT1(aSegment.start, false); 
    147                                                         this._segplayer.setT2(aSegment.end, false); 
    148                                                         if (aSegment.segmentOwner) { 
    149                                                                 aSegment.segmentOwner.segGainFocus(aSegment); 
    150                                                         } 
    151                                                 } 
    152  
    153                                         ]]> 
    154 </body> 
    155 </method> 
    156 <field name="focusedSegment"/> 
    157 <method name="beginBatch"> 
    158 <body> 
    159 <![CDATA[ 
    160                                                 //FIXME: disable input events 
    161                                                 this._suspendId = this.innerSvg.suspendRedraw(0); 
    162                                                 this.statusEditor |= 4; 
    163                                         ]]> 
    164 </body> 
    165 </method> 
    166 <method name="refresh"> 
    167                                  
    168 <body> 
    169 <![CDATA[ 
    170                                                 var child; 
    171                                                 var i; 
    172                                                 //Utiliser un treeWalker 
    173                                                 for (i = 0; i < this.childNodes.length; i++) { 
    174                                                         child = this.childNodes[i]; 
    175                                                         if (child.localName == "area") { 
    176                                                                 child.init(this); 
    177                                                         } 
    178                                                 } 
    179                                                 //Memoire du point de cut. 
    180                                                 delete this._TimeToCut; 
    181  
    182                                                 //On sort du mode batch avant le refresh du focus. 
    183                                                 this.statusEditor ^= 4; 
    184  
    185                                                 //Gestion du focus 
    186                                                 var vNewFocus = null; 
    187                                                 if(this.focusedSegment) { 
    188                                                         var vParent = this.focusedSegment.parentNode; 
    189                                                         while(vParent) { 
    190                                                                 if(vParent === this) { 
    191                                                                         //Ce segment est toujours dans la hiérachie. 
    192                                                                         vNewFocus = this.focusedSegment; 
    193                                                                         break; 
    194                                                                 } 
    195                                                                 vParent = vParent.parentNode; 
    196                                                         } 
    197                                                 } 
    198                                                 this.setFocusOnSegment(vNewFocus); 
    199  
    200             this.updatePlot(); 
    201                                                 this.innerSvg.unsuspendRedraw(this._suspendId); 
    202  
    203                                         ]]> 
    204 </body> 
    205 </method> 
    206 <method name="s2Str"> 
    207 <parameter name="aMs"/> 
    208 <parameter name="round"/> 
    209 <body> 
    210 <![CDATA[ 
    211                                                 var resStr = ""; 
    212                                                 var resDouble; 
    213  
    214                                                 resDouble = aMs % 60; 
    215                                                 if (round != null) 
    216                                                         resDouble = Math.floor(resDouble * Math.pow(10, round)) / Math.pow(10, round); 
    217                                                 resStr = ((resDouble < 10) ? "0" + resDouble : resDouble); 
    218                                                 resStr += ""; 
    219                                                 if (round && round != 0) { 
    220                                                         while (resStr.length < (round + 3)) { 
    221                                                                         if (resStr.length == 2) resStr += "."; 
    222                                                                         resStr += "0"; 
    223                                                         } 
    224                                                 } 
    225  
    226                                                 aMs = Math.floor(aMs / 60); 
    227                                                 resDouble = (aMs % 60) 
    228                                                 resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
    229  
    230                                                 aMs = Math.floor(aMs / 60); 
    231                                                 resDouble = (aMs % 60); 
    232                                                 resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
    233  
    234                                                 return resStr; 
    235                                         ]]> 
    236 </body> 
    237 </method> 
    238 <method name="removeSection"> 
    239 <parameter name="pSection"/>  
    240 <body>  
    241             <![CDATA[  
    242               if (pSection == this.focusedSegment) { 
    243                 this.setFocusOnSegment(null); 
    244               } 
    245                                                         var vParentSection = pSection.parentSection;  
    246               try { 
    247                 pSection.parentNode.removeChild(pSection);  
    248               } catch(e) {} 
    249               vParentSection.init(this); 
    250                                                         var sectionWalker = vParentSection.ownerArea.newSectionWalker(); 
    251                                                         while (sectionWalker.nextNode()) { 
    252                 sectionWalker.currentNode.updateStartRequest(null); 
    253                                                         } 
    254               var vUpdatedSegments = this.getUpdatedSegmentsAndCompute(vParentSection);  
    255               this.updatePlot(); 
    256               this.setFocusOnSegment(this.focusedSegment); 
    257               return vUpdatedSegments;  
    258                                                 ]]> 
    259 </body> 
    260 </method> 
    261 <method name="init"> 
    262 <parameter name="aAudioObject"/> 
    263 <body> 
    264 <![CDATA[ 
    265  
     105                                                        this._zoomplayer.setT1(x1 - ((t2 - t1) - (x2 - x1)) / 2, true); 
     106                                                        this._zoomplayer.setT2(this._zoomplayer.t1 + t2 - t1, true); 
     107                                                } 
     108                                        } else { 
     109                                                this._zoomplayer.setT1(x1 - (x2 - x1) / 2, true); 
     110                                                this._zoomplayer.setT2(x2 + (x2 - x1) / 2, true); 
     111                                        } 
     112                                ]]></body> 
     113                        </method> 
     114                        <method name="setFocusOnSegment"> 
     115                                <parameter name="aSegment" /> 
     116                                <body><![CDATA[ 
     117                                        if (!this.srcAudio) return; 
     118                                        if (this.focusedSegment && !(aSegment === this.focusedSegment )) { 
     119                                                this.focusedSegment.removeAttribute("checked"); 
     120                                                if (this.focusedSegment.segmentOwner) { 
     121                                                        this.focusedSegment.segmentOwner.segLooseFocus(this.focusedSegment); 
     122                                                } 
     123                                        } 
     124                                        this.focusedSegment = aSegment; 
     125                                        if( (this.statusEditor & 4) == 4) return; //en cours de batch, on recalculera tout ca plus tard.  
     126                                        if (!aSegment) { 
     127                                                this._segplayer.showZone(false); 
     128                                                this._segplayer.setText("left", ""); 
     129                                                this._segplayer.setText("right", ""); 
     130                                        } else { 
     131                                                this._segplayer.setText("left", aSegment.getAttribute("title")); 
     132                                                this._segplayer.setText("right", 
     133                                                        "(" + this.s2Str(aSegment.start * (this.duration / 1000), 0) + "-" + 
     134                                                        this.s2Str((aSegment.end) * (this.duration / 1000), 0) + ") " + 
     135                                                        this.s2Str((aSegment.end - aSegment.start) * (this.duration / 1000), 2)); 
     136                                                aSegment.setAttribute("checked", "true"); 
     137                                                this._segplayer.setT1(aSegment.start, false); 
     138                                                this._segplayer.setT2(aSegment.end, false); 
     139                                                if (aSegment.segmentOwner) { 
     140                                                        aSegment.segmentOwner.segGainFocus(aSegment); 
     141                                                } 
     142                                        } 
     143                                ]]></body> 
     144                        </method> 
     145                        <field name="focusedSegment" /> 
     146                        <method name="beginBatch"> 
     147                                <body><![CDATA[ 
     148                                        //FIXME: disable input events 
     149                                        this._suspendId = this.innerSvg.suspendRedraw(0); 
     150                                        this.statusEditor |= 4; 
     151                                ]]></body> 
     152                        </method> 
     153                        <method name="refresh"> 
     154                                <body><![CDATA[ 
     155                                        var child; 
     156                                        var i; 
     157                                        //Utiliser un treeWalker 
     158                                        for (i = 0; i < this.childNodes.length; i++) { 
     159                                                child = this.childNodes[i]; 
     160                                                if (child.localName == "area") { 
     161                                                        child.init(this); 
     162                                                } 
     163                                        } 
     164                                        //Memoire du point de cut. 
     165                                        delete this._TimeToCut; 
     166 
     167                                        //On sort du mode batch avant le refresh du focus. 
     168                                        this.statusEditor ^= 4; 
     169 
     170                                        //Gestion du focus 
     171                                        var vNewFocus = null; 
     172                                        if(this.focusedSegment) { 
     173                                                var vParent = this.focusedSegment.parentNode; 
     174                                                while(vParent) { 
     175                                                        if(vParent === this) { 
     176                                                                //Ce segment est toujours dans la hiérachie. 
     177                                                                vNewFocus = this.focusedSegment; 
     178                                                                break; 
     179                                                        } 
     180                                                        vParent = vParent.parentNode; 
     181                                                } 
     182                                        } 
     183                                        this.setFocusOnSegment(vNewFocus); 
     184 
     185          this.updatePlot(); 
     186                                        this.innerSvg.unsuspendRedraw(this._suspendId); 
     187 
     188                                ]]></body> 
     189                        </method> 
     190                        <method name="s2Str"> 
     191                                <parameter name="aMs" /> 
     192                                <parameter name="round" /> 
     193                                <body><![CDATA[ 
     194                                        var resStr = ""; 
     195                                        var resDouble; 
     196 
     197                                        resDouble = aMs % 60; 
     198                                        if (round != null) 
     199                                                resDouble = Math.floor(resDouble * Math.pow(10, round)) / Math.pow(10, round); 
     200                                        resStr = ((resDouble < 10) ? "0" + resDouble : resDouble); 
     201                                        resStr += ""; 
     202                                        if (round && round != 0) { 
     203                                                while (resStr.length < (round + 3)) { 
     204                                                                if (resStr.length == 2) resStr += "."; 
     205                                                                resStr += "0"; 
     206                                                } 
     207                                        } 
     208 
     209                                        aMs = Math.floor(aMs / 60); 
     210                                        resDouble = (aMs % 60) 
     211                                        resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
     212 
     213                                        aMs = Math.floor(aMs / 60); 
     214                                        resDouble = (aMs % 60); 
     215                                        resStr = ((resDouble < 10) ? "0" + resDouble : resDouble) + ":" + resStr; 
     216 
     217                                        return resStr; 
     218                                ]]></body> 
     219                        </method> 
     220                        <method name="removeSection"> 
     221                                <parameter name="pSection" /> 
     222                                <body><![CDATA[  
     223          if (pSection == this.focusedSegment) { 
     224            this.setFocusOnSegment(null); 
     225          } 
     226                                        var vParentSection = pSection.parentSection;  
     227          try { 
     228            pSection.parentNode.removeChild(pSection);  
     229          } catch(e) {} 
     230          vParentSection.init(this); 
     231                                        var sectionWalker = vParentSection.ownerArea.newSectionWalker(); 
     232                                        while (sectionWalker.nextNode()) { 
     233            sectionWalker.currentNode.updateStartRequest(null); 
     234                                        } 
     235          var vUpdatedSegments = this.getUpdatedSegmentsAndCompute(vParentSection);  
     236          this.updatePlot(); 
     237          this.setFocusOnSegment(this.focusedSegment); 
     238          return vUpdatedSegments;  
     239                                ]]></body> 
     240                        </method> 
     241                        <method name="init"> 
     242                                <parameter name="aAudioObject" /> 
     243                                <body><![CDATA[ 
    266244                                        var self = this; 
    267245                                        this.playState = "stop"; 
     
    530508 
    531509                                        this.updatePlot(); 
    532                                         ]]> 
    533 </body> 
    534 </method> 
    535  
    536                          
    537 <property name="audioStream"> 
    538 <getter> 
    539 <![CDATA[ 
    540                                                  
    541                                                 if (!this.srcAudio) 
    542                                                         return null; 
    543                                                 if (!this._audioStream) { 
    544                                                         this._audioStream = Components.classes["@scenari.org/audio/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); 
    545                                                         this._audioStream.init(this.srcAudio, 1, 0, Components.interfaces.nsIFileInputStream.REOPEN_ON_REWIND); 
    546                                                         this._audioStream.QueryInterface(Components.interfaces.scIAudioStream); 
    547                                                 } 
    548                                                  
    549                                                 return this._audioStream; 
    550  
    551                                         ]]> 
    552 </getter> 
    553 </property> 
    554                          
    555 <method name="play"> 
    556 <parameter name="t1"/> 
    557 <parameter name="t2"/> 
    558 <body> 
    559 <![CDATA[ 
    560                                                 if (t1 < 0) t1 = 0; 
    561                                                 var f1 = t1 * this._sampleRate; 
    562  
    563                                                 var f2; 
    564  
    565                                                 if (t2 < 0) { 
    566                                                         t2 = this._duration; 
    567                                                 } 
    568                                                 f2 = t2 * this._sampleRate; 
    569  
    570                                                 if (!this._audioPlayer) { 
    571                                                         var gAudioSrvc = Components.classes['@scenari.org/audio-service;1'].getService(Components.interfaces.scIAudioService); 
    572                                                         this._audioPlayer = gAudioSrvc.newAudioPlayer(-1, this.audioStream); 
    573                                                         this._audioPlayer.contentStream = this.audioStream; 
    574  
    575                                                         this._audioPlayer.frameSegmentSize  = 512; 
    576                                                         this._audioPlayer.frameSegmentCount = 10; 
    577  
    578                                                 } 
    579                                                 this.audioStream.seekFrame(0, f1); 
    580                                                 this._offset = t1 / this._duration; 
    581                                                 this._window = (t2 - t1) / this._duration; 
    582                                                 this._audioPlayer.notificationCallbacks = this._playerListener; 
    583                                                 this._audioPlayer.asyncWrite(this._playerListener, null, f2 - f1, false); 
    584                                         ]]> 
    585 </body> 
    586 </method> 
    587 <method name="stop"> 
    588 <body> 
    589 <![CDATA[ 
    590                                                 this._mainplayer.stopplay(); 
    591                                                 this._zoomplayer.stopplay(); 
    592                                                 this._segplayer.stopplay(); 
    593                                                 this.playState = "stop"; 
    594  
    595                                                 if (this._audioPlayer) { 
    596                                                         this._playerListener.cancel(); 
    597                                                 } 
    598                                         ]]> 
    599 </body> 
    600 </method> 
    601                          
    602 <method name="createSection"> 
    603 <body> 
    604 <![CDATA[ 
     510                                ]]></body> 
     511                        </method> 
     512 
     513                        <property name="audioStream"> 
     514                                <getter><![CDATA[ 
     515                                        if (!this.srcAudio) 
     516                                                return null; 
     517                                        if (!this._audioStream) { 
     518                                                this._audioStream = Components.classes["@scenari.org/audio/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); 
     519                                                this._audioStream.init(this.srcAudio, 1, 0, Components.interfaces.nsIFileInputStream.REOPEN_ON_REWIND); 
     520                                                this._audioStream.QueryInterface(Components.interfaces.scIAudioStream); 
     521                                        } 
    605522                                         
     523                                        return this._audioStream; 
     524                                ]]></getter> 
     525                        </property> 
     526 
     527                        <method name="play"> 
     528                                <parameter name="t1" /> 
     529                                <parameter name="t2" /> 
     530                                <body><![CDATA[ 
     531                                        if (t1 < 0) t1 = 0; 
     532                                        var f1 = t1 * this._sampleRate; 
     533 
     534                                        var f2; 
     535 
     536                                        if (t2 < 0) { 
     537                                                t2 = this._duration; 
     538                                        } 
     539                                        f2 = t2 * this._sampleRate; 
     540 
     541                                        if (!this._audioPlayer) { 
     542                                                var gAudioSrvc = Components.classes['@scenari.org/audio-service;1'].getService(Components.interfaces.scIAudioService); 
     543                                                this._audioPlayer = gAudioSrvc.newAudioPlayer(-1, this.audioStream); 
     544                                                this._audioPlayer.contentStream = this.audioStream; 
     545 
     546                                                this._audioPlayer.frameSegmentSize  = 512; 
     547                                                this._audioPlayer.frameSegmentCount = 10; 
     548 
     549                                        } 
     550                                        this.audioStream.seekFrame(0, f1); 
     551                                        this._offset = t1 / this._duration; 
     552                                        this._window = (t2 - t1) / this._duration; 
     553                                        this._audioPlayer.notificationCallbacks = this._playerListener; 
     554                                        this._audioPlayer.asyncWrite(this._playerListener, null, f2 - f1, false); 
     555                                ]]></body> 
     556                        </method> 
     557                        <method name="stop"> 
     558                                <body><![CDATA[ 
     559                                        this._mainplayer.stopplay(); 
     560                                        this._zoomplayer.stopplay(); 
     561                                        this._segplayer.stopplay(); 
     562                                        this.playState = "stop"; 
     563 
     564                                        if (this._audioPlayer) { 
     565                                                this._playerListener.cancel(); 
     566                                        } 
     567                                ]]></body> 
     568                        </method> 
     569 
     570                        <method name="createSection"> 
     571                                <body><![CDATA[ 
    606572                                        var g = document.createElementNS("http://www.w3.org/2000/svg", "g"); 
    607573                                        var aSection = document.createElementNS("http://www.w3.org/2000/svg", "section"); 
    608574                                        aSection.appendChild(g); 
    609575                                        return aSection; 
    610                                         ]]> 
    611 </body> 
    612 </method> 
    613  
    614  
    615                          
    616 <method name="forceRedraw"> 
    617 <body> 
    618 <![CDATA[ 
    619                                                 this.innerSvg.style.display = "none"; 
    620                                                 this.innerSvg.style.display = "block"; 
    621                                                 this._zoomarea.style.display = "none"; 
    622                                                 this._zoomarea.style.display = "block"; 
    623                                         ]]> 
    624 </body> 
    625 </method> 
    626 <method name="redraw"> 
    627 <body> 
    628 <![CDATA[ 
     576                                ]]></body> 
     577                        </method> 
     578 
     579                        <method name="forceRedraw"> 
     580                                <body><![CDATA[ 
     581                                        this.innerSvg.style.display = "none"; 
     582                                        this.innerSvg.style.display = "block"; 
     583                                        this._zoomarea.style.display = "none"; 
     584                                        this._zoomarea.style.display = "block"; 
     585                                ]]></body> 
     586                        </method> 
     587 
     588                        <method name="redraw"> 
     589                                <body><![CDATA[ 
    629590                                                this.innerSvg.style.visibility = "hidden"; 
    630591                                                this.innerSvg.style.visibility = "visible"; 
    631592                                                this._zoomarea.style.visibility = "hidden"; 
    632593                                                this._zoomarea.style.visibility = "visible"; 
    633                                         ]]> 
    634 </body> 
    635 </method> 
    636 <method name="getUpdatedSegmentsAndCompute"> 
    637 <parameter name="aSegment"/> 
    638 <body> 
    639 <![CDATA[ 
     594                                ]]></body> 
     595                        </method> 
     596 
     597                        <method name="getUpdatedSegmentsAndCompute"> 
     598                                <parameter name="aSegment" /> 
     599                                <body><![CDATA[ 
    640600                                        var sectionWalker = aSegment.ownerArea.newSectionWalker(); 
    641601                                        var updatedSegments = new Array(); 
     
    648608                                        } 
    649609                                        return updatedSegments; 
    650                                         ]]> 
    651 </body> 
    652 </method> 
    653  
    654 <property name="innerSvg" readonly="true"> 
    655 <getter> 
    656 <![CDATA[ 
    657                                                 return document.getAnonymousElementByAttribute(this, "anonid", "svgbody"); 
    658                                         ]]> 
    659 </getter> 
    660 </property> 
    661 <property name="inner" readonly="true"> 
    662 <getter> 
    663 <![CDATA[ 
    664                                                 return document.getAnonymousNodes(this)[0]; 
    665                                         ]]> 
    666 </getter> 
    667 </property> 
    668  
    669 <method name="updateZoom"> 
    670 <parameter name="x1"/> 
    671 <parameter name="x2"/> 
    672 <body> 
    673 <![CDATA[ 
     610                                ]]></body> 
     611                        </method> 
     612 
     613                        <property name="innerSvg" readonly="true"> 
     614                                <getter><![CDATA[ 
     615                                        return document.getAnonymousElementByAttribute(this, "anonid", "svgbody"); 
     616                                ]]></getter> 
     617                        </property> 
     618                         
     619                        <property name="inner" readonly="true"> 
     620                                <getter><![CDATA[ 
     621                                        return document.getAnonymousNodes(this)[0]; 
     622                                ]]></getter> 
     623                        </property> 
     624 
     625                        <method name="updateZoom"> 
     626                                <parameter name="x1" /> 
     627                                <parameter name="x2" /> 
     628                                <body><![CDATA[ 
    674629                                        this._mark1.x1.baseVal.value = this._ground.width.baseVal.value * x1 / 1000 + this._ground.x.baseVal.value; 
    675630                                        this._mark2.x1.baseVal.value = this._ground.width.baseVal.value * x2 / 1000 + this._ground.x.baseVal.value; 
    676631                                        this._zoomarea.setAttribute("viewBox", x1 + " 0 " + (x2 - x1) + " 100"); 
    677                                         ]]> 
    678 </body> 
    679 </method> 
    680  
    681 <property name="duration"> 
    682 <getter> 
    683 <![CDATA[ 
    684                                                 return this._duration;           
    685                                         ]]> 
    686 </getter> 
    687 </property> 
    688  
    689 <method name="askForCutRequest"> 
    690 <body> 
    691 <![CDATA[ 
    692                                                 if (this.cursor <= 0) return; 
    693  
    694                                                 var child; 
    695                                                 var i; 
    696                                                 for (i = 0; i < this.childNodes.length; i++) { 
    697                                                         child = this.childNodes[i]; 
    698                                                         if (child.localName == "area") { 
    699                                                                 var sectionWalker = child.newSectionWalker(); 
    700                                                                 var vNode; 
    701                                                                 while ( (vNode = sectionWalker.nextNode()) ) { 
    702                                                                         if ((vNode.start < this.cursor) && (vNode.end > this.cursor)) { 
    703                                                                                 if (vNode.segmentOwner) { 
    704                                                                                         //Mem cursor position. 
    705                                                                                         this._TimeToCut = this.cursor * this.duration / 1000; 
    706                                                                                         vNode.segmentOwner.segAskForCut(vNode, 0); 
    707                                                                                         //Impossible : l'odre d'insertion par le XED est asynchrone. => Reporté dans le refresh() 
    708                                                                                         //delete this._TimeToCut; 
    709                                                                                 } 
    710                                                                                 return; 
     632                                ]]></body> 
     633                        </method> 
     634 
     635                        <property name="duration"> 
     636                                <getter><![CDATA[ 
     637                                        return this._duration;           
     638                                ]]></getter> 
     639                        </property> 
     640 
     641                        <method name="askForCutRequest"> 
     642                                <body><![CDATA[ 
     643                                        if (this.cursor <= 0) return; 
     644 
     645                                        var child; 
     646                                        var i; 
     647                                        for (i = 0; i < this.childNodes.length; i++) { 
     648                                                child = this.childNodes[i]; 
     649                                                if (child.localName == "area") { 
     650                                                        var sectionWalker = child.newSectionWalker(); 
     651                                                        var vNode; 
     652                                                        while ( (vNode = sectionWalker.nextNode()) ) { 
     653                                                                if ((vNode.start < this.cursor) && (vNode.end > this.cursor)) { 
     654                                                                        if (vNode.segmentOwner) { 
     655                                                                                //Mem cursor position. 
     656                                                                                this._TimeToCut = this.cursor * this.duration / 1000; 
     657                                                                                vNode.segmentOwner.segAskForCut(vNode, 0); 
     658                                                                                //Impossible : l'odre d'insertion par le XED est asynchrone. => Reporté dans le refresh() 
     659                                                                                //delete this._TimeToCut; 
    711660                                                                        } 
     661                                                                        return; 
    712662                                                                } 
    713663                                                        } 
    714664                                                } 
    715  
    716  
    717                                         ]]> 
    718 </body> 
    719 </method> 
    720 <method name="updatePlot"> 
    721 <body> 
    722 <![CDATA[ 
     665                                        } 
     666                                ]]></body> 
     667                        </method> 
     668                        <method name="updatePlot"> 
     669                                <body><![CDATA[ 
    723670                                        var plotbox = document.getAnonymousElementByAttribute(this, "anonid", "plotbox"); 
    724671                                        while (plotbox.hasChildNodes()) { 
     
    745692                                                } 
    746693                                        } 
    747  
    748  
    749                                         ]]> 
    750 </body> 
    751 </method> 
    752 <method name="playFromCursor"> 
    753 <body> 
    754 <![CDATA[ 
    755                                                 var self = this; 
    756  
    757  
    758                                                 this.stop(); 
    759                                                 this.replayFromCursor = true; 
    760                                         ]]> 
    761 </body> 
    762 </method> 
    763 <property name="cursor"> 
    764 <setter> 
    765 <![CDATA[ 
    766                                                 this._mainplayer.cursor = val; 
    767                                                 this._segplayer.cursor = val; 
    768                                                 this._zoomplayer.cursor = val; 
    769  
    770                                                 var i; 
    771                                                 var child; 
    772                                                 for (i = 0; i < this.childNodes.length; i++) { 
    773                                                 child = this.childNodes[i]; 
    774                                                         if (child.localName == "area") { 
    775                                                                 child.cursor = val; 
    776                                                         } 
    777                                                 } 
    778  
    779                                                 ]]> 
    780 </setter> 
    781 <getter> 
    782 <![CDATA[ 
    783                                                         return this._mainplayer.cursor; 
    784                                                 ]]> 
    785 </getter> 
    786 </property> 
    787  
    788 </implementation> 
    789 </binding> 
     694                                ]]></body> 
     695                        </method> 
     696                        <method name="playFromCursor"> 
     697                                <body><![CDATA[ 
     698                                        var self = this; 
     699                                        this.stop(); 
     700                                        this.replayFromCursor = true; 
     701                                ]]></body> 
     702                        </method> 
     703                         
     704                        <property name="cursor"> 
     705                                <setter><![CDATA[ 
     706                                        this._mainplayer.cursor = val; 
     707                                        this._segplayer.cursor = val; 
     708                                        this._zoomplayer.cursor = val; 
     709 
     710                                        var i; 
     711                                        var child; 
     712                                        for (i = 0; i < this.childNodes.length; i++) { 
     713                                        child = this.childNodes[i]; 
     714                                                if (child.localName == "area") { 
     715                                                        child.cursor = val; 
     716                                                } 
     717                                        } 
     718                                ]]></setter> 
     719                                <getter><![CDATA[ 
     720                                        return this._mainplayer.cursor; 
     721                                ]]></getter> 
     722                        </property> 
     723 
     724                </implementation> 
     725        </binding> 
    790726 
    791727 
Note: See TracChangeset for help on using the changeset viewer.