* Device.safariVersion now holds the major version of the Safari browser.

* Device.edge is a boolean that is set if running under the Microsoft Edge browser.
* Device.dolby is a boolean that is set if the browser can play EC-3 Dolby Digital Plus files
* The Loader and SoundManager can now play Dolby Digital Plus files on supported devices.
This commit is contained in:
Richard Davey 2016-02-09 13:17:14 +00:00
parent 332fb6fe68
commit 92479eb03f
2 changed files with 60 additions and 2 deletions

View file

@ -313,6 +313,10 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* The Grunt script has been updated to enhance the intro / outro and Pixi defaults. Pixi has been split into intro / outro and main blocks, so you can exclude its intro cleanly. The excludes are now bound, so if you exclude the Phaser UMD it will do the same for Pixi as well (thanks @spayton #2192)
* ArcadePhysics.worldAngleToPointer will get the angle (in radians) between a display object and the pointer, taking all parent rotations into account (thanks @mattrick16 #2171)
* There is new documentation on building Phaser for Webpack and a new custom build grunt option (thanks @deiga #2331)
* Device.safariVersion now holds the major version of the Safari browser.
* Device.edge is a boolean that is set if running under the Microsoft Edge browser.
* Device.dolby is a boolean that is set if the browser can play EC-3 Dolby Digital Plus files
* The Loader and SoundManager can now play Dolby Digital Plus files on supported devices.
### Updates

View file

@ -310,6 +310,12 @@ Phaser.Device = function () {
*/
this.tridentVersion = 0;
/**
* @property {boolean} edge - Set to true if running in Microsoft Edge browser.
* @default
*/
this.edge = false;
/**
* @property {boolean} mobileSafari - Set to true if running in Mobile Safari.
* @default
@ -334,6 +340,12 @@ Phaser.Device = function () {
*/
this.safari = false;
/**
* @property {number} safariVersion - If running in Safari this will contain the major version number.
* @default
*/
this.safariVersion = 0;
/**
* @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView
* @default
@ -397,6 +409,12 @@ Phaser.Device = function () {
*/
this.webm = false;
/**
* @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files?
* @default
*/
this.dolby = false;
// Video
/**
@ -896,9 +914,14 @@ Phaser.Device._initialize = function () {
{
device.opera = true;
}
else if (/Safari/.test(ua) && !device.windowsPhone)
else if (/Safari\/(\d+)/.test(ua) && !device.windowsPhone)
{
device.safari = true;
if (/Version\/(\d+)\./.test(ua))
{
device.safariVersion = parseInt(RegExp.$1, 10);
}
}
else if (/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(ua))
{
@ -907,6 +930,10 @@ Phaser.Device._initialize = function () {
device.tridentVersion = parseInt(RegExp.$1, 10);
device.ieVersion = parseInt(RegExp.$3, 10);
}
else if (/Edge\/\d+/.test(ua))
{
device.edge = true;
}
// Silk gets its own if clause because its ua also contains 'Safari'
if (/Silk/.test(ua))
@ -1051,6 +1078,29 @@ Phaser.Device._initialize = function () {
{
device.webm = true;
}
if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '')
{
if (device.edge)
{
device.dolby = true;
}
else if (device.safari && device.safariVersion >= 9)
{
var ua = navigator.userAgent;
if (/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent))
{
var major = parseInt(RegExp.$1, 10);
var minor = parseInt(RegExp.$2, 10);
if ((major === 10 && minor >= 11) || major > 10)
{
device.dolby = true;
}
}
}
}
}
} catch (e) {
}
@ -1188,9 +1238,9 @@ Phaser.Device._initialize = function () {
// Run the checks
_checkOS();
_checkBrowser();
_checkAudio();
_checkVideo();
_checkBrowser();
_checkCSS3D();
_checkDevice();
_checkFeatures();
@ -1233,6 +1283,10 @@ Phaser.Device.canPlayAudio = function (type) {
{
return true;
}
else if (type === 'mp4' && this.dolby)
{
return true;
}
return false;