Index: trunk/extensions/OggHandler/OggPlayer.js |
— | — | @@ -346,7 +346,52 @@ |
347 | 347 | } |
348 | 348 | return hasObj; |
349 | 349 | }, |
| 350 | + 'webkitVersionIsAtLeast' : function ( minimumString ) { |
| 351 | + var version = function() { |
| 352 | + // grab (AppleWebKit/)(xxx.x.x) |
| 353 | + var webKitFields = RegExp("( AppleWebKit/)([^ ]+)").exec(navigator.userAgent); |
| 354 | + if (!webKitFields || webKitFields.length < 3) |
| 355 | + return null; |
| 356 | + var versionString = webKitFields[2]; |
| 357 | + var isNightlyBuild = versionString.indexOf("+") != -1; |
350 | 358 | |
| 359 | + // Remove '+' or any other stray characters |
| 360 | + var invalidCharacter = RegExp("[^\\.0-9]").exec(versionString); |
| 361 | + if (invalidCharacter) |
| 362 | + versionString = versionString.slice(0, invalidCharacter.index); |
| 363 | + |
| 364 | + var version = versionString.split("."); |
| 365 | + version.isNightlyBuild = isNightlyBuild; |
| 366 | + return version; |
| 367 | + } |
| 368 | + var toIntOrZero = function (s) { |
| 369 | + var toInt = parseInt(s); |
| 370 | + return isNaN(toInt) ? 0 : toInt; |
| 371 | + } |
| 372 | + |
| 373 | + if (minimumString === undefined) |
| 374 | + minimumString = ""; |
| 375 | + |
| 376 | + var minimum = minimumString.split("."); |
| 377 | + var version = version(); |
| 378 | + |
| 379 | + if (!version) |
| 380 | + return false; |
| 381 | + |
| 382 | + if (version.isNightlyBuild) |
| 383 | + return true; |
| 384 | + |
| 385 | + for (var i = 0; i < minimum.length; i++) { |
| 386 | + var versionField = toIntOrZero(version[i]); |
| 387 | + var minimumField = toIntOrZero(minimum[i]); |
| 388 | + |
| 389 | + if (versionField > minimumField) |
| 390 | + return true; |
| 391 | + if (versionField < minimumField) |
| 392 | + return false; |
| 393 | + } |
| 394 | + return true; |
| 395 | + }, |
351 | 396 | 'addOption' : function ( select, value, text, selected ) { |
352 | 397 | var option = document.createElement( 'option' ); |
353 | 398 | option.value = value; |
— | — | @@ -550,7 +595,7 @@ |
551 | 596 | ' height=' + this.hq( (params.height>0)?params.height:this.controlsHeightGuess ) + |
552 | 597 | ' src=' + this.hq( params.videoUrl ) + |
553 | 598 | ' autoplay'; |
554 | | - if (!this.safari) |
| 599 | + if (!this.safari || this.webkitVersionIsAtLeast('530.19.2')) |
555 | 600 | html += ' controls'; |
556 | 601 | html += ' ></' + mtag + '></div>'; |
557 | 602 | elt.innerHTML = html; |