Changeset 155


Ignore:
Timestamp:
02/05/09 03:08:50 (4 years ago)
Author:
jeroen
Message:

made accessibility not start when there's no captions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/as3/com/jeroenwijering/plugins/Accessibility.as

    r149 r155  
    8484        public function initializePlugin(vie:AbstractView):void { 
    8585                view = vie; 
     86                if(view.config['audio']) { config['audio'] = view.config['audio']; } 
     87                if(view.config['captions']) { config['captions'] = view.config['captions']; } 
     88                if(!config['captions'] && !config['audio']) { 
     89                        clip.visible = false; 
     90                        return; 
     91                } 
    8692                view.addControllerListener(ControllerEvent.ITEM,itemHandler); 
    8793                view.addControllerListener(ControllerEvent.RESIZE,resizeHandler); 
     
    9096                clip.tf.autoSize = TextFieldAutoSize.CENTER; 
    9197                format = new TextFormat(null,config['fontsize']); 
    92                 if(view.config['audio']) { config['audio'] = view.config['audio']; } 
    93                 if(view.config['captions']) { config['captions'] = view.config['captions']; } 
    9498                hide(config['hide']); 
    9599                mute(config['mute']); 
     
    172176        }; 
    173177 
    174         /** Set buttons in the controlbar **/  
     178        /** Set buttons in the controlbar **/ 
    175179        private function setButtons():void { 
    176180                if(config['captions']) { 
     
    228232        /** Check timing of the player to sync captions. **/ 
    229233        private function timeHandler(evt:ModelEvent):void { 
    230                 if(captions.length == 0) { 
    231                         return;  
    232                 } 
    233234                var cur:Number = -1; 
    234235                var pos:Number = evt.data.position; 
    235                 // sync up the captions (only if needed). 
     236                // sync up the captions if needed. 
    236237                for(var i:Number=0; i<captions.length; i++) { 
    237238                        if(captions[i]['begin'] < pos && captions[i]['end'] > pos) { 
     
    240241                        } 
    241242                } 
    242                 if(cur != current) { setCaption(cur); } 
    243                 // and sync up the audio (only if needed). 
     243                if(cur > -1 && cur != current) { 
     244                        setCaption(cur); 
     245                } 
     246                // sync up the audio if needed. 
    244247                if(channel && view.config['state'] == ModelStates.PLAYING && Math.abs(pos-channel.position/1000) > 0.5) { 
    245248                        channel.stop(); 
Note: See TracChangeset for help on using the changeset viewer.