| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <title>JW Player Testing</title> |
|---|
| 4 | <link rel="stylesheet" href="files/style.css" type="text/css"> |
|---|
| 5 | <script type="text/javascript" src="files/jquery.js"></script> |
|---|
| 6 | <script type="text/javascript" src="files/swfobject.js"></script> |
|---|
| 7 | <script type="text/javascript" src="files/settings.js"></script> |
|---|
| 8 | <script type="text/javascript"> |
|---|
| 9 | $(document).ready(function() { |
|---|
| 10 | $.extend({ |
|---|
| 11 | /** Insert a new example in the page. **/ |
|---|
| 12 | insert: function(evt) { |
|---|
| 13 | evt.preventDefault(); |
|---|
| 14 | var obj = settings.examples[$('#examples :selected').text()]; |
|---|
| 15 | var arr = []; |
|---|
| 16 | if(obj['plugins']) { |
|---|
| 17 | arr = obj['plugins'].split(','); |
|---|
| 18 | } |
|---|
| 19 | $('#plugins').val(arr); |
|---|
| 20 | $.fieldsets(); |
|---|
| 21 | $.fillout("flashvarsform"); |
|---|
| 22 | }, |
|---|
| 23 | /** Fill out the flashvars with example data. **/ |
|---|
| 24 | fillout: function(set) { |
|---|
| 25 | var obj = settings.examples[$('#examples :selected').text()]; |
|---|
| 26 | var arr = $("#"+set).find('input'); |
|---|
| 27 | for(var i=0; i<arr.length; i++) { |
|---|
| 28 | var nam = $(arr[i]).attr('name'); |
|---|
| 29 | if(obj[nam] == null) { |
|---|
| 30 | $(arr[i]).val(''); |
|---|
| 31 | } else { |
|---|
| 32 | $(arr[i]).val(obj[nam]); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | $("#flashvarsform").submit(); |
|---|
| 36 | }, |
|---|
| 37 | /** Set the tab functions. **/ |
|---|
| 38 | tabs: function() { |
|---|
| 39 | $('li').click(function() { |
|---|
| 40 | $('li').removeClass('active'); |
|---|
| 41 | $(this).addClass('active'); |
|---|
| 42 | var itm = $(this).text().toLowerCase(); |
|---|
| 43 | $.tab($.trim(itm)); |
|---|
| 44 | }); |
|---|
| 45 | }, |
|---|
| 46 | /** Flip to a tab. **/ |
|---|
| 47 | tab: function(itm) { |
|---|
| 48 | var arr = $("#flashvarsform").find('fieldset'); |
|---|
| 49 | for(var i=0; i<arr.length; i++) { |
|---|
| 50 | if($(arr[i]).attr('id') == itm) { |
|---|
| 51 | $(arr[i]).css('display','block'); |
|---|
| 52 | } else { |
|---|
| 53 | $(arr[i]).css('display','none'); |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | }, |
|---|
| 57 | /** Check for inserting of fieldsets. **/ |
|---|
| 58 | fieldsets: function(evt) { |
|---|
| 59 | $("#fieldsettabs > .plugin").remove(); |
|---|
| 60 | $("#fieldsetspan").empty(); |
|---|
| 61 | var str = $("#plugins").val(); |
|---|
| 62 | if(str != null) { |
|---|
| 63 | arr = str.toString().split(','); |
|---|
| 64 | for (var i=0; i<arr.length; i++) { |
|---|
| 65 | var swf = settings.plugins[arr[i]].swf; |
|---|
| 66 | var xml = settings.plugins[arr[i]].xml; |
|---|
| 67 | $.fieldset(xml,arr[i]); |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | }, |
|---|
| 71 | /** Insert a specific plugin fieldset. **/ |
|---|
| 72 | fieldset: function(url,nam) { |
|---|
| 73 | $.get(url,{},function(xml) { |
|---|
| 74 | var arr = $('flashvars',xml).find('flashvar'); |
|---|
| 75 | if(arr.length > 0) { |
|---|
| 76 | var tit = nam.substr(0,1).toUpperCase()+nam.substr(1); |
|---|
| 77 | $("#fieldsettabs").append('<li class="plugin">'+tit+'</li>'); |
|---|
| 78 | $.tabs(); |
|---|
| 79 | var set = '<fieldset id="'+nam+'">'; |
|---|
| 80 | for (var i=0; i<arr.length; i++) { |
|---|
| 81 | var val = $('name',arr[i]).text(); |
|---|
| 82 | set +='<label>'+val+'</label><input type="text" name="'+nam+'.'+val+'" />'; |
|---|
| 83 | } |
|---|
| 84 | set += '</fieldset>'; |
|---|
| 85 | $('#fieldsetspan').append(set); |
|---|
| 86 | $.fillout(nam); |
|---|
| 87 | } |
|---|
| 88 | }); |
|---|
| 89 | }, |
|---|
| 90 | /** Reload the flashvars into the player. **/ |
|---|
| 91 | reload: function(evt) { |
|---|
| 92 | evt.preventDefault(); |
|---|
| 93 | var vrs = {}; |
|---|
| 94 | var arr = $("#flashvarsform").find('input'); |
|---|
| 95 | for(var i=0; i<arr.length; i++) { |
|---|
| 96 | if($(arr[i]).val()) { |
|---|
| 97 | vrs[$(arr[i]).attr('name')] = $(arr[i]).val(); |
|---|
| 98 | } |
|---|
| 99 | } |
|---|
| 100 | if($("#skins").val() != 'none') { |
|---|
| 101 | vrs['skin'] = settings.skins[$("#skins").val()]; |
|---|
| 102 | } |
|---|
| 103 | if($("#plugins").val() != null) { |
|---|
| 104 | var plg = ''; |
|---|
| 105 | var arr = $("#plugins").val(); |
|---|
| 106 | for(var i=0; i<arr.length; i++) { |
|---|
| 107 | plg += settings.plugins[arr[i]].swf+','; |
|---|
| 108 | } |
|---|
| 109 | vrs['plugins'] = plg.substr(0,plg.length-1); |
|---|
| 110 | } |
|---|
| 111 | $('#preview').css('height',vrs['height']); |
|---|
| 112 | $('#preview').html('<div id="container"></div>'); |
|---|
| 113 | swfobject.embedSWF( |
|---|
| 114 | settings.players[$('#players').val()], |
|---|
| 115 | 'container', |
|---|
| 116 | vrs['width'], |
|---|
| 117 | vrs['height'], |
|---|
| 118 | '9.0.0', |
|---|
| 119 | null, |
|---|
| 120 | vrs, |
|---|
| 121 | {allowfullscreen:'true',allowscriptaccess:'always'}, |
|---|
| 122 | {id:'ply',name:'ply'} |
|---|
| 123 | ); |
|---|
| 124 | }, |
|---|
| 125 | /** Get a variable from the player. **/ |
|---|
| 126 | getVariable: function(evt) { |
|---|
| 127 | evt.preventDefault(); |
|---|
| 128 | switch($('#vartype').val().toString()) { |
|---|
| 129 | case 'config': |
|---|
| 130 | var obj = player.getConfig(); |
|---|
| 131 | break; |
|---|
| 132 | case 'playlist': |
|---|
| 133 | var obj = player.getPlaylist(); |
|---|
| 134 | break; |
|---|
| 135 | case 'plugin.config': |
|---|
| 136 | var obj = player.getPluginConfig($('#configplugin').val()); |
|---|
| 137 | break; |
|---|
| 138 | } |
|---|
| 139 | $.alert(obj); |
|---|
| 140 | }, |
|---|
| 141 | /** Send an event to the player. **/ |
|---|
| 142 | sendEvent: function(evt) { |
|---|
| 143 | evt.preventDefault(); |
|---|
| 144 | player.sendEvent($('#sendevent').val(),$('#sendeventdata').val()); |
|---|
| 145 | }, |
|---|
| 146 | /** Set a listener to the player. **/ |
|---|
| 147 | setListener: function(evt) { |
|---|
| 148 | evt.preventDefault(); |
|---|
| 149 | var arr = $('#eventtype').val().toString().split(': '); |
|---|
| 150 | var sel = $('#addremove').val().toString(); |
|---|
| 151 | var fcn = '$.alert'; |
|---|
| 152 | if(arr.length == 2 && sel == 'add') { |
|---|
| 153 | if(arr[0] == 'Model') { |
|---|
| 154 | player.addModelListener(arr[1],fcn); |
|---|
| 155 | } else { |
|---|
| 156 | player.addControllerListener(arr[1],fcn); |
|---|
| 157 | } |
|---|
| 158 | } else if(arr.length == 2 && sel == 'remove') { |
|---|
| 159 | if(arr[0] == 'Model') { |
|---|
| 160 | player.removeModelListener(arr[1],fcn); |
|---|
| 161 | } else { |
|---|
| 162 | player.removeControllerListener(arr[1],fcn); |
|---|
| 163 | } |
|---|
| 164 | } |
|---|
| 165 | }, |
|---|
| 166 | /** Alert responses from the player. **/ |
|---|
| 167 | alert: function(obj) { |
|---|
| 168 | var txt = ''; |
|---|
| 169 | for (itm in obj) { |
|---|
| 170 | if(typeof(obj[itm]) == 'object') { |
|---|
| 171 | txt += itm+':\n'; |
|---|
| 172 | for (ent in obj[itm]) { |
|---|
| 173 | txt += ' '+ent+': '+obj[itm][ent]+'\n'; |
|---|
| 174 | } |
|---|
| 175 | } else { |
|---|
| 176 | txt += itm+': '+obj[itm]+'\n'; |
|---|
| 177 | } |
|---|
| 178 | } |
|---|
| 179 | alert(txt); |
|---|
| 180 | } |
|---|
| 181 | }); |
|---|
| 182 | /** Attach handlers to all buttons and select fields. **/ |
|---|
| 183 | $("#examples").change(function(evt) { $.insert(evt); }); |
|---|
| 184 | $("#players").change(function(evt) { $.reload(evt); }); |
|---|
| 185 | $("#skins").change(function(evt) { $.reload(evt); }); |
|---|
| 186 | $("#plugins").change(function(evt) { $.fieldsets(evt); }); |
|---|
| 187 | $("#examplesform").submit(function(evt) { $.insert(evt); }); |
|---|
| 188 | $("#flashvarsform").submit(function(evt) { $.reload(evt); }); |
|---|
| 189 | $("#variablesform").submit(function(evt) { $.getVariable(evt); }); |
|---|
| 190 | $("#sendeventform").submit(function(evt) { $.sendEvent(evt); }); |
|---|
| 191 | $("#listenersform").submit(function(evt) { $.setListener(evt); }); |
|---|
| 192 | /** Load all settings into the player. **/ |
|---|
| 193 | for (dct in settings) { |
|---|
| 194 | for (itm in settings[dct]) { |
|---|
| 195 | $("#"+dct).append("<option>"+itm+"</option>"); |
|---|
| 196 | } |
|---|
| 197 | } |
|---|
| 198 | $.tabs(); |
|---|
| 199 | $('#examplesform').css('display','block'); |
|---|
| 200 | $('#sources').css('display','block'); |
|---|
| 201 | }); |
|---|
| 202 | </script> |
|---|
| 203 | |
|---|
| 204 | </head> |
|---|
| 205 | <body> |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | <form id="examplesform"> |
|---|
| 209 | <fieldset> |
|---|
| 210 | <label>Example</label> |
|---|
| 211 | <select name="examples" id="examples"></select> |
|---|
| 212 | </fieldset> |
|---|
| 213 | <button type="submit" id="examplesbutton">Insert example</button> |
|---|
| 214 | </form> |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | <div id="javascript"> |
|---|
| 220 | <form id="variablesform"> |
|---|
| 221 | <fieldset> |
|---|
| 222 | <label>Variable</label> |
|---|
| 223 | <select type="text" id="vartype"> |
|---|
| 224 | <option>config</option> |
|---|
| 225 | <option>playlist</option> |
|---|
| 226 | <option>plugin.config</option> |
|---|
| 227 | </select> |
|---|
| 228 | <label>Plugin</label> |
|---|
| 229 | <input type="text" id="configplugin" /> |
|---|
| 230 | </fieldset> |
|---|
| 231 | <button type="submit" id="variablesbutton">Get variable</button> |
|---|
| 232 | </form> |
|---|
| 233 | <form id="sendeventform"> |
|---|
| 234 | <fieldset> |
|---|
| 235 | <label>Event</label> |
|---|
| 236 | <select type="text" id="sendevent"> |
|---|
| 237 | <option>LINK</option> |
|---|
| 238 | <option>LOAD</option> |
|---|
| 239 | <option>MUTE</option> |
|---|
| 240 | <option>NEXT</option> |
|---|
| 241 | <option>ITEM</option> |
|---|
| 242 | <option>PLAY</option> |
|---|
| 243 | <option>PREV</option> |
|---|
| 244 | <option>REDRAW</option> |
|---|
| 245 | <option>SEEK</option> |
|---|
| 246 | <option>STOP</option> |
|---|
| 247 | <option>VOLUME</option> |
|---|
| 248 | </select> |
|---|
| 249 | <label>Data</label> |
|---|
| 250 | <input type="text" id="sendeventdata" /> |
|---|
| 251 | </fieldset> |
|---|
| 252 | <button type="submit" id="sendeventbutton">Send event</button> |
|---|
| 253 | </form> |
|---|
| 254 | <form id="listenersform"> |
|---|
| 255 | <fieldset> |
|---|
| 256 | <label>Type</label> |
|---|
| 257 | <select type="text" id="addremove"> |
|---|
| 258 | <option>add</option> |
|---|
| 259 | <option>remove</option> |
|---|
| 260 | </select> |
|---|
| 261 | <label>Event</label> |
|---|
| 262 | <select type="text" id="eventtype"> |
|---|
| 263 | <option>Controller: ERROR</option> |
|---|
| 264 | <option>Controller: ITEM</option> |
|---|
| 265 | <option>Controller: MUTE</option> |
|---|
| 266 | <option>Controller: PLAY</option> |
|---|
| 267 | <option>Controller: PLAYLIST</option> |
|---|
| 268 | <option>Controller: RESIZE</option> |
|---|
| 269 | <option>Controller: SEEK</option> |
|---|
| 270 | <option>Controller: STOP</option> |
|---|
| 271 | <option>Controller: VOLUME</option> |
|---|
| 272 | <option></option> |
|---|
| 273 | <option>Model: BUFFER</option> |
|---|
| 274 | <option>Model: ERROR</option> |
|---|
| 275 | <option>Model: LOADED</option> |
|---|
| 276 | <option>Model: META</option> |
|---|
| 277 | <option>Model: STATE</option> |
|---|
| 278 | <option>Model: TIME</option> |
|---|
| 279 | </select> |
|---|
| 280 | </fieldset> |
|---|
| 281 | <button type="submit" id="listenersbutton">Set listener</button> |
|---|
| 282 | </form> |
|---|
| 283 | </div> |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | <div id="preview"> |
|---|
| 289 | <a href="readme.html">Learn how to use this testing page</a></div> |
|---|
| 290 | </div> |
|---|
| 291 | |
|---|
| 292 | <script type="text/javascript"> |
|---|
| 293 | var player; |
|---|
| 294 | function playerReady(obj) { |
|---|
| 295 | player = document.getElementById(obj['id']); |
|---|
| 296 | $('#javascript').css('display','block'); |
|---|
| 297 | }; |
|---|
| 298 | </script> |
|---|
| 299 | |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | <form id="flashvarsform"> |
|---|
| 305 | <ul id="fieldsettabs"> |
|---|
| 306 | <li class="active">Sources</li> |
|---|
| 307 | <li>Properties</li> |
|---|
| 308 | <li>Layout</li> |
|---|
| 309 | <li>Behaviour</li> |
|---|
| 310 | <li>Miscellaneous</li> |
|---|
| 311 | </ul> |
|---|
| 312 | <fieldset></fieldset> |
|---|
| 313 | <fieldset id="sources"> |
|---|
| 314 | <label>player</label> |
|---|
| 315 | <select id="players"></select> |
|---|
| 316 | <label>skin</label> |
|---|
| 317 | <select id="skins"></select> |
|---|
| 318 | <label>plugins</label> |
|---|
| 319 | <select multiple="multiple" id="plugins"></select> |
|---|
| 320 | </fieldset> |
|---|
| 321 | <fieldset id="properties"> |
|---|
| 322 | <label>author</label> |
|---|
| 323 | <input type="text" name="date" /> |
|---|
| 324 | <label>date</label> |
|---|
| 325 | <input type="text" name="author" /> |
|---|
| 326 | <label>description</label> |
|---|
| 327 | <input type="text" name="description" /> |
|---|
| 328 | <label>duration</label> |
|---|
| 329 | <input type="text" name="duration" /> |
|---|
| 330 | <label>file</label> |
|---|
| 331 | <input type="text" name="file" /> |
|---|
| 332 | <label>image</label> |
|---|
| 333 | <input type="text" name="image" /> |
|---|
| 334 | <label>link</label> |
|---|
| 335 | <input type="text" name="link" /> |
|---|
| 336 | <label>start</label> |
|---|
| 337 | <input type="text" name="start" /> |
|---|
| 338 | <label>streamer</label> |
|---|
| 339 | <input type="text" name="streamer" /> |
|---|
| 340 | <label>tags</label> |
|---|
| 341 | <input type="text" name="tags" /> |
|---|
| 342 | <label>title</label> |
|---|
| 343 | <input type="text" name="title" /> |
|---|
| 344 | <label>type</label> |
|---|
| 345 | <input type="text" name="type" /> |
|---|
| 346 | </fieldset> |
|---|
| 347 | <fieldset id="layout"> |
|---|
| 348 | <label>backcolor</label> |
|---|
| 349 | <input type="text" name="backcolor" /> |
|---|
| 350 | <label>controlbar</label> |
|---|
| 351 | <input type="text" name="controlbar" /> |
|---|
| 352 | <label>frontcolor</label> |
|---|
| 353 | <input type="text" name="frontcolor" /> |
|---|
| 354 | <label>height</label> |
|---|
| 355 | <input type="text" name="height" value="260" /> |
|---|
| 356 | <label>lightcolor</label> |
|---|
| 357 | <input type="text" name="lightcolor" /> |
|---|
| 358 | <label>playlist</label> |
|---|
| 359 | <input type="text" name="playlist" /> |
|---|
| 360 | <label>playlistsize</label> |
|---|
| 361 | <input type="text" name="playlistsize" /> |
|---|
| 362 | <label>screencolor</label> |
|---|
| 363 | <input type="text" name="screencolor" /> |
|---|
| 364 | <label>width</label> |
|---|
| 365 | <input type="text" name="width" value="400" /> |
|---|
| 366 | </fieldset> |
|---|
| 367 | <fieldset id="behaviour"> |
|---|
| 368 | <label>autostart</label> |
|---|
| 369 | <input type="text" name="autostart" /> |
|---|
| 370 | <label>bufferlength</label> |
|---|
| 371 | <input type="text" name="bufferlength" /> |
|---|
| 372 | <label>displayclick</label> |
|---|
| 373 | <input type="text" name="displayclick" /> |
|---|
| 374 | <label>icons</label> |
|---|
| 375 | <input type="text" name="icons" /> |
|---|
| 376 | <label>item</label> |
|---|
| 377 | <input type="text" name="item" /> |
|---|
| 378 | <label>logo</label> |
|---|
| 379 | <input type="text" name="logo" /> |
|---|
| 380 | <label>mute</label> |
|---|
| 381 | <input type="text" name="mute" /> |
|---|
| 382 | <label>replace</label> |
|---|
| 383 | <input type="text" name="replace" /> |
|---|
| 384 | <label>repeat</label> |
|---|
| 385 | <input type="text" name="repeat" /> |
|---|
| 386 | <label>resizing</label> |
|---|
| 387 | <input type="text" name="resizing" /> |
|---|
| 388 | <label>respectduration</label> |
|---|
| 389 | <input type="text" name="respectduration" /> |
|---|
| 390 | <label>shuffle</label> |
|---|
| 391 | <input type="text" name="shuffle" /> |
|---|
| 392 | <label>smoothing</label> |
|---|
| 393 | <input type="text" name="smoothing" /> |
|---|
| 394 | <label>stretching</label> |
|---|
| 395 | <input type="text" name="stretching" /> |
|---|
| 396 | <label>volume</label> |
|---|
| 397 | <input type="text" name="volume" /> |
|---|
| 398 | </fieldset> |
|---|
| 399 | <fieldset id="miscellaneous"> |
|---|
| 400 | <label>abouttext</label> |
|---|
| 401 | <input type="text" name="abouttext" /> |
|---|
| 402 | <label>aboutlink</label> |
|---|
| 403 | <input type="text" name="aboutlink" /> |
|---|
| 404 | <label>config</label> |
|---|
| 405 | <input type="text" name="config" /> |
|---|
| 406 | <label>id</label> |
|---|
| 407 | <input type="text" name="id" /> |
|---|
| 408 | <label>linktarget</label> |
|---|
| 409 | <input type="text" name="linktarget" /> |
|---|
| 410 | </fieldset> |
|---|
| 411 | <span id="fieldsetspan"></span> |
|---|
| 412 | <button type="submit" id="flashvarsbutton">Reload player</button> |
|---|
| 413 | </form> |
|---|
| 414 | |
|---|
| 415 | |
|---|
| 416 | |
|---|
| 417 | </body> |
|---|
| 418 | </html> |
|---|