Changeset 211


Ignore:
Timestamp:
05/09/09 20:14:50 (4 years ago)
Author:
jeroen
Message:

added a Logger class for debugging.

Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • testing/index.html

    r210 r211  
    109109                                        vrs['plugins'] = plg.substr(0,plg.length-1); 
    110110                                } 
    111                                 vrs['tracecall'] = 'arthropod'; 
    112111                                $('#preview').css('height',vrs['height']); 
    113112                                $('#preview').html('<div id="container"></div>'); 
     
    377376                <label>height</label> 
    378377                <input type="text" name="height" value="260" /> 
     378                <label>icons</label> 
     379                <input type="text" name="icons" /> 
    379380                <label>lightcolor</label> 
    380381                <input type="text" name="lightcolor" /> 
     
    395396                <label>displayclick</label> 
    396397                <input type="text" name="displayclick" /> 
    397                 <label>icons</label> 
    398                 <input type="text" name="icons" /> 
    399398                <label>item</label> 
    400399                <input type="text" name="item" /> 
     400                <label>linktarget</label> 
     401                <input type="text" name="linktarget" /> 
    401402                <label>logo</label> 
    402403                <input type="text" name="logo" /> 
     
    417418        </fieldset> 
    418419        <fieldset id="miscellaneous"> 
    419                 <label>abouttext</label> 
    420                 <input type="text" name="abouttext" /> 
    421                 <label>aboutlink</label> 
    422                 <input type="text" name="aboutlink" /> 
    423420                <label>config</label> 
    424421                <input type="text" name="config" /> 
     422                <label>debug</label> 
     423                <input type="text" name="debug" /> 
    425424                <label>id</label> 
    426425                <input type="text" name="id" /> 
    427                 <label>linktarget</label> 
    428                 <input type="text" name="linktarget" /> 
    429426        </fieldset> 
    430427        <span id="fieldsetspan"></span> 
  • trunk/as3/com/jeroenwijering/parsers/ItunesParser.as

    r169 r211  
    1212 
    1313        /** Prefix for the iTunes namespace. **/ 
    14         private static var PREFIX = 'itunes'; 
     14        private static const PREFIX = 'itunes'; 
    1515 
    1616 
  • trunk/as3/com/jeroenwijering/parsers/JWParser.as

    r161 r211  
    1212 
    1313        /** Prefix for the JW Player namespace. **/ 
    14         private static var PREFIX = 'jwplayer'; 
     14        private static const PREFIX = 'jwplayer'; 
    1515 
    1616 
  • trunk/as3/com/jeroenwijering/parsers/MediaParser.as

    r190 r211  
    1212 
    1313        /** Prefix for the JW Player namespace. **/ 
    14         private static var PREFIX = 'media'; 
     14        private static const PREFIX = 'media'; 
    1515 
    1616 
  • trunk/as3/com/jeroenwijering/player/Controller.as

    r210 r211  
    109109        /** Catch errors dispatched by the playlister. **/ 
    110110        private function errorHandler(evt:ErrorEvent):void { 
    111                 dispatchEvent(new ControllerEvent(ControllerEvent.ERROR,{message:evt.text})); 
     111                sendEvent(ControllerEvent.ERROR,{message:evt.text}); 
    112112        }; 
    113113 
     
    230230                        var fmt:String = dat.localName().toLowerCase(); 
    231231                } catch (err:Error) { 
    232                         dispatchEvent(new ControllerEvent(ControllerEvent.ERROR,{message:'This playlist is not a valid XML file.'})); 
     232                        sendEvent(ControllerEvent.ERROR,{message:'This playlist is not a valid XML file.'}); 
    233233                        return; 
    234234                } 
     
    250250                                break; 
    251251                        default: 
    252                                 dispatchEvent(new ControllerEvent(ControllerEvent.ERROR,{message:'Unknown playlist format: '+fmt})); 
     252                                sendEvent(ControllerEvent.ERROR,{message:'Unknown playlist format: '+fmt}); 
    253253                                return; 
    254254                } 
     
    280280                } 
    281281                Configger.saveCookie('mute',config['mute']); 
    282                 dispatchEvent(new ControllerEvent(ControllerEvent.MUTE,{state:config['mute']})); 
     282                sendEvent(ControllerEvent.MUTE,{state:config['mute']}); 
    283283        }; 
    284284 
     
    300300                if(playlist) { 
    301301                        if(evt.data.state != false && config['state'] == ModelStates.PAUSED) { 
    302                                 dispatchEvent(new ControllerEvent(ControllerEvent.PLAY,{state:true})); 
     302                                sendEvent(ControllerEvent.PLAY,{state:true}); 
    303303                        } else if (evt.data.state != false && config['state'] == ModelStates.COMPLETED) { 
    304                                 dispatchEvent(new ControllerEvent(ControllerEvent.SEEK,{position:0})); 
     304                                sendEvent(ControllerEvent.SEEK,{position:0}); 
    305305                        } else if(evt.data.state != false && config['state'] == ModelStates.IDLE) { 
    306306                                playItem(); 
    307307                        } else if (evt.data.state != true && 
    308308                                (config['state'] == ModelStates.PLAYING || config['state'] == ModelStates.BUFFERING)) { 
    309                                 dispatchEvent(new ControllerEvent(ControllerEvent.PLAY,{state:false})); 
     309                                sendEvent(ControllerEvent.PLAY,{state:false}); 
    310310                        } 
    311311                } 
     
    318318                        config['item'] = nbr; 
    319319                } 
    320                 dispatchEvent(new ControllerEvent(ControllerEvent.ITEM,{index:config['item']})); 
     320                sendEvent(ControllerEvent.ITEM,{index:config['item']}); 
    321321        }; 
    322322 
     
    336336                        playlist = ply; 
    337337                } else { 
    338                         dispatchEvent(new ControllerEvent(ControllerEvent.ERROR,{message:'No valid filetypes found in this playlist'})); 
     338                        sendEvent(ControllerEvent.ERROR,{message:'No valid filetypes found in this playlist'}); 
    339339                        return; 
    340340                } 
     
    345345                        config['item'] = playlist.length-1; 
    346346                } 
    347                 dispatchEvent(new ControllerEvent(ControllerEvent.PLAYLIST,{playlist:playlist})); 
     347                sendEvent(ControllerEvent.PLAYLIST,{playlist:playlist}); 
    348348                if(config['autostart'] == true) { 
    349349                        playItem(); 
     
    378378                        sploader.layoutNormal(); 
    379379                } 
    380                 dispatchEvent(new ControllerEvent(ControllerEvent.RESIZE,{ 
    381                         fullscreen:config['fullscreen'],width:config['width'],height:config['height']})); 
     380                sendEvent(ControllerEvent.RESIZE,{ 
     381                        fullscreen:config['fullscreen'],width:config['width'],height:config['height']}); 
    382382        }; 
    383383 
     
    389389                        if(pos < 1) {  
    390390                                pos = 0; 
    391                         } else if (pos > playlist[config['item']]['duration']-1) {  
     391                        } else if (pos > playlist[config['item']]['duration']-1) { 
    392392                                pos = playlist[config['item']]['duration']-1; 
    393393                        } 
    394                         dispatchEvent(new ControllerEvent(ControllerEvent.SEEK,{position:pos})); 
    395                 } 
     394                        sendEvent(ControllerEvent.SEEK,{position:pos}); 
     395                } 
     396        }; 
     397 
     398 
     399        /** Log and dispatch events. **/ 
     400        private function sendEvent(typ:String,dat:Object=undefined):void { 
     401                Logger.log(dat,typ); 
     402                dispatchEvent(new ControllerEvent(typ,dat)); 
    396403        }; 
    397404 
     
    399406        /** Stop all playback and buffering. **/ 
    400407        private function stopHandler(evt:ViewEvent=undefined):void { 
    401                 dispatchEvent(new ControllerEvent(ControllerEvent.STOP)); 
     408                sendEvent(ControllerEvent.STOP); 
    402409        }; 
    403410 
     
    439446                        config['volume'] = vol; 
    440447                        Configger.saveCookie('volume',config['volume']); 
    441                         dispatchEvent(new ControllerEvent(ControllerEvent.VOLUME,{percentage:vol})); 
     448                        sendEvent(ControllerEvent.VOLUME,{percentage:vol}); 
    442449                } 
    443450        }; 
  • trunk/as3/com/jeroenwijering/player/Model.as

    r210 r211  
    195195                                        break; 
    196196                        } 
    197                         dispatchEvent(new ModelEvent(typ,dat)); 
    198                 } else { 
    199                         dispatchEvent(new ModelEvent(typ,dat)); 
    200                         if(dat.width) { resizeHandler(); } 
    201                 } 
     197                } else if(dat.width) { 
     198                        resizeHandler(); 
     199                } 
     200                Logger.log(dat,typ); 
     201                dispatchEvent(new ModelEvent(typ,dat)); 
    202202        }; 
    203203 
  • trunk/as3/com/jeroenwijering/player/Player.as

    r210 r211  
    99import com.jeroenwijering.plugins.*; 
    1010import com.jeroenwijering.utils.Configger; 
     11import com.jeroenwijering.utils.Logger; 
    1112 
    1213import flash.display.MovieClip; 
     
    4041                dock:true, 
    4142                height:300, 
     43                icons:true, 
    4244                playlist:'none', 
    4345                playlistsize:180, 
     
    4951                displayclick:'play', 
    5052                fullscreen:false, 
    51                 icons:true, 
    5253                item:0, 
     54                linktarget:'_blank', 
    5355                logo:undefined, 
    5456                mute:false, 
     
    6163                volume:90, 
    6264 
    63                 abouttext:undefined, 
     65                abouttext:"JW Player", 
    6466                aboutlink:"http://www.longtailvideo.com/players/jw-flv-player/", 
    6567                client:undefined, 
     68                debug:'none', 
    6669                id:undefined, 
    67                 linktarget:'_blank', 
    68                 token:undefined, 
    69                 tracecall:undefined, 
    70                 version:'4.5.208' 
     70                plugins:undefined, 
     71                version:'4.5.211' 
    7172        }; 
    7273        /** Reference to all stage graphics. **/ 
     
    110111        /** When config is loaded, the player laods the skin. **/ 
    111112        protected function loadSkin(evt:Event=null):void { 
     113                Logger.output = config['debug']; 
    112114                sploader = new SPLoader(this); 
    113115                sploader.addEventListener(SPLoaderEvent.SKIN,loadMVC); 
  • trunk/as3/com/jeroenwijering/player/View.as

    r190 r211  
    9494                if(prm.length > 0) { 
    9595                        prm = '('+prm.substr(0,prm.length-1)+')'; 
    96                 } 
    97                 if(config['tracecall'] == 'arthropod') { 
    98                         var obj:Object = {CONTROLLER:'0xFF6666',VIEW:'0x66FF66',MODEL:'0x6666FF'}; 
    99                         Debug.log(typ+' '+prm,obj[tgt]); 
    100                 } else if(config['tracecall'] == 'flash') { 
    101                         trace(tgt+': '+typ+' '+prm); 
    102                 } else if (config['tracecall'] && ready) { 
    103                         ExternalInterface.call(config['tracecall'],tgt+': '+typ+' '+prm); 
    10496                } 
    10597                if(!dat) { dat = new Object(); } 
     
    286278                                break; 
    287279                } 
     280                Logger.log(prm,typ); 
    288281                dispatchEvent(new ViewEvent(typ,dat)); 
    289282        }; 
  • trunk/as3/com/jeroenwijering/plugins/Rightclick.as

    r170 r211  
    66 
    77import com.jeroenwijering.events.*; 
     8import com.jeroenwijering.utils.Logger; 
     9import com.jeroenwijering.utils.Stretcher; 
    810 
    911import flash.events.ContextMenuEvent; 
    1012import flash.net.URLRequest; 
    1113import flash.net.navigateToURL; 
     14import flash.system.Capabilities; 
    1215import flash.ui.ContextMenu; 
    1316import flash.ui.ContextMenuItem; 
     
    2730        /** Reference to the stretchmode menuitem. **/ 
    2831        private var stretching:ContextMenuItem; 
     32        /** Reference to the debugging menuitem. **/ 
     33        private var debug:ContextMenuItem; 
    2934        /** Reference to the MVC view. **/ 
    3035        private var view:AbstractView; 
     
    3843 
    3944 
    40         /** 
    41         * Add an item to the contextmenu. 
    42         * 
    43         * @param itm    An initialized ContextMenuItem 
    44         * @param fcn    The function to call when the menuitem is clicked. 
    45         **/ 
    46         public function addItem(itm:ContextMenuItem,fcn:Function):void { 
     45        /** Add an item to the contextmenu. **/ 
     46        private function addItem(itm:ContextMenuItem,fcn:Function):void { 
    4747                itm.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,fcn); 
    4848                itm.separatorBefore = true; 
     
    5555                view = vie; 
    5656                view.skin.contextMenu = context; 
     57                // Add the 'fullscreen' menuitem. 
    5758                try { 
    58                         if(view.skin.stage['displayState']) { 
    59                                 fullscreen = new ContextMenuItem('Toggle fullscreen...'); 
    60                                 addItem(fullscreen,fullscreenHandler); 
    61                         } 
     59                        fullscreen = new ContextMenuItem('Toggle Fullscreen...'); 
     60                        addItem(fullscreen,fullscreenHandler); 
    6261                } catch (err:Error) {} 
     62                // Add the 'stretching' menuitem. 
    6363                stretching = new ContextMenuItem('Stretching is '+view.config['stretching']+'...'); 
    6464                addItem(stretching,stretchHandler); 
    65                 if(view.config['abouttext']) { 
    66                         about = new ContextMenuItem(view.config['abouttext']+'...'); 
     65                // Add the 'about' menuitem. 
     66                if(view.config['abouttext'] == 'JW Player' || view.config['abouttext'] == undefined) { 
     67                        about = new ContextMenuItem('About JW Player '+view.config['version']+'...'); 
    6768                } else { 
    68                         about = new ContextMenuItem('About JW Player '+view.config['version']+'...'); 
     69                        about = new ContextMenuItem('About '+view.config['abouttext']+'...'); 
    6970                } 
    7071                addItem(about,aboutHandler); 
     72                // Add the 'debug' menuitem. 
     73                if(Capabilities.isDebugger == true || view.config['debug'] != 'none') { 
     74                        debug = new ContextMenuItem('Logging to '+Logger.output+'...'); 
     75                        addItem(debug,debugHandler); 
     76                } 
    7177        }; 
    7278 
     
    7884 
    7985 
     86        /** change the debug system. **/ 
     87        private function debugHandler(evt:ContextMenuEvent):void { 
     88                var arr:Array = new Array(Logger.NONE,Logger.ARTHROPOD,Logger.CONSOLE,Logger.TRACE); 
     89                var idx:Number = arr.indexOf(Logger.output); 
     90                idx == arr.length-1 ? idx = 0: idx++; 
     91                debug.caption = 'Logging to '+arr[idx]+'...'; 
     92                Logger.output = arr[idx]; 
     93        }; 
     94 
     95 
    8096        /** Toggle the fullscreen mode. **/ 
    81         private function fullscreenHandler(evt:ContextMenuEvent):void {  
     97        private function fullscreenHandler(evt:ContextMenuEvent):void { 
    8298                view.sendEvent(ViewEvent.FULLSCREEN); 
    8399        }; 
     
    86102        /** Change the stretchmode. **/ 
    87103        private function stretchHandler(evt:ContextMenuEvent):void { 
    88                 var arr:Array = new Array('uniform','fill','exactfit','none'); 
    89                 for (var idx:Number = 0; idx<arr.length; idx++) { 
    90                         if(arr[idx] == view.config['stretching']) { 
    91                                 break; 
    92                         } 
    93                 } 
     104                var arr:Array = new Array(Stretcher.UNIFORM,Stretcher.FILL,Stretcher.EXACTFIT,Stretcher.NONE); 
     105                var idx:Number = arr.indexOf(view.config['stretching']); 
    94106                idx == arr.length-1 ? idx = 0: idx++; 
    95107                view.config['stretching'] = arr[idx]; 
    96                 stretching.caption = 'Stretching is '+view.config['stretching']+'...'; 
     108                stretching.caption = 'Stretching is '+arr[idx]+'...'; 
    97109                view.sendEvent(ViewEvent.REDRAW); 
    98110        }; 
  • trunk/as3/com/jeroenwijering/plugins/Watermark.as

    r189 r211  
    11/** 
    2 * Plugin that shows a watermark when buffering§. 
     2* Plugin that shows a watermark when buffering. 
    33**/ 
    44package com.jeroenwijering.plugins { 
     
    3333                out: 0.5 
    3434        }; 
    35         /** URL to redirect to on mouse click **/ 
    36         private var clickURL:String = "http://www.longtailvideo.com/players/jw-flv-player/"; 
    3735        /** Set to true when the watermark is visible **/ 
    3836        private var showing:Boolean = false; 
     
    7270        private function resizeHandler(evt:ControllerEvent):void { 
    7371                config = view.getPluginConfig(this); 
    74                 this.x = config['x'] + 10; 
    75                 this.y = config['height'] - this.height - 12; 
     72                x = config['x'] + 10; 
     73                y = config['height'] - height - 12; 
    7674        }; 
    7775 
     
    110108        /** Handle Mouse Click **/ 
    111109        private function clickHandler(evt:MouseEvent):void { 
    112                 navigateToURL(new URLRequest(clickURL),"_self"); 
     110                view.sendEvent(ViewEvent.PLAY,false); 
     111                navigateToURL(new URLRequest(view.config['aboutlink'])); 
    113112        }; 
    114113 
  • trunk/sdk/testing.html

    r184 r211  
    142142                        sendEvent: function(evt) { 
    143143                                evt.preventDefault(); 
    144                                 player.sendEvent($('#sendevent').val(),$('#sendeventdata').val()); 
     144                                var typ = $('#sendevent').val(); 
     145                                var dat = $('#sendeventdata').val(); 
     146                                if(typ == 'LOAD' && dat.indexOf(':') > 0) { 
     147                                        var arr = new Array(); 
     148                                        var ply = dat.split(';'); 
     149                                        for(var i=0; i<ply.length; i++) { 
     150                                                var obj = new Object(); 
     151                                                var itm = ply[i].split(','); 
     152                                                for(var j=0; j<itm.length; j++) { 
     153                                                        obj[itm[j].split(':')[0]] = itm[j].split(':')[1]; 
     154                                                } 
     155                                                arr.push(obj); 
     156                                        } 
     157                                        if(arr.length > 1) { 
     158                                                dat = arr; 
     159                                        } else {  
     160                                                dat = obj; 
     161                                        } 
     162                                } 
     163                                player.sendEvent(typ,dat); 
    145164                        }, 
    146165                        /** Set a listener to the player. **/ 
     
    235254                        <label>Event</label> 
    236255                        <select type="text" id="sendevent"> 
     256                                <option>ITEM</option> 
    237257                                <option>LINK</option> 
    238258                                <option>LOAD</option> 
    239259                                <option>MUTE</option> 
    240260                                <option>NEXT</option> 
    241                                 <option>ITEM</option> 
    242261                                <option>PLAY</option> 
    243262                                <option>PREV</option> 
     
    287306 
    288307<div id="preview"> 
    289 <a href="readme.html">Learn how to use this testing page</a></div> 
     308<p>Testing is simple: choose an example, change the flashvars and see if it works.<br/> 
     309You can also download this testing page as part of the <a href="http://developer.longtailvideo.com/trac/changeset/HEAD/trunk/sdk?old_path=/&format=zip">plugin development SDK</a>.</p> 
    290310</div> 
    291311 
     
    350370                <label>controlbar</label> 
    351371                <input type="text" name="controlbar" /> 
     372                <label>dock</label> 
     373                <input type="text" name="dock" /> 
    352374                <label>frontcolor</label> 
    353375                <input type="text" name="frontcolor" /> 
    354376                <label>height</label> 
    355377                <input type="text" name="height" value="260" /> 
     378                <label>icons</label> 
     379                <input type="text" name="icons" /> 
    356380                <label>lightcolor</label> 
    357381                <input type="text" name="lightcolor" /> 
     
    372396                <label>displayclick</label> 
    373397                <input type="text" name="displayclick" /> 
    374                 <label>icons</label> 
    375                 <input type="text" name="icons" /> 
    376398                <label>item</label> 
    377399                <input type="text" name="item" /> 
     400                <label>linktarget</label> 
     401                <input type="text" name="linktarget" /> 
    378402                <label>logo</label> 
    379403                <input type="text" name="logo" /> 
    380404                <label>mute</label> 
    381405                <input type="text" name="mute" /> 
    382                 <label>replace</label> 
    383                 <input type="text" name="replace" /> 
    384406                <label>repeat</label> 
    385407                <input type="text" name="repeat" /> 
    386408                <label>resizing</label> 
    387409                <input type="text" name="resizing" /> 
    388                 <label>respectduration</label> 
    389                 <input type="text" name="respectduration" /> 
    390410                <label>shuffle</label> 
    391411                <input type="text" name="shuffle" /> 
     
    398418        </fieldset> 
    399419        <fieldset id="miscellaneous"> 
    400                 <label>abouttext</label> 
    401                 <input type="text" name="abouttext" /> 
    402                 <label>aboutlink</label> 
    403                 <input type="text" name="aboutlink" /> 
    404420                <label>config</label> 
    405421                <input type="text" name="config" /> 
     422                <label>debug</label> 
     423                <input type="text" name="debug" /> 
    406424                <label>id</label> 
    407425                <input type="text" name="id" /> 
    408                 <label>linktarget</label> 
    409                 <input type="text" name="linktarget" /> 
    410426        </fieldset> 
    411427        <span id="fieldsetspan"></span> 
Note: See TracChangeset for help on using the changeset viewer.