Device.canPlayAudio now supports the opus files directly, as well as opus encoded audio stored in ogg containers (#1232)

This commit is contained in:
photonstorm 2014-10-13 13:52:41 +01:00
parent 88a97b935b
commit 5d84f38f6e
2 changed files with 7 additions and 2 deletions

View file

@ -82,6 +82,7 @@ Version 2.1.3 - "Ravinda" - in development
* Changed the Animation constructor parameter `delay` to `frameRate` as it's a more accurate term of what it should be. Internally nothing changed.
* Circle.getBounds added.
* Ellipse.getBounds added.
* Device.canPlayAudio now supports the `opus` files directly, as well as `opus` encoded audio stored in ogg containers (#1232)
### Bug Fixes

View file

@ -712,7 +712,7 @@ Phaser.Device.prototype = {
this.ogg = true;
}
if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '')) {
if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) {
this.opus = true;
}
@ -876,7 +876,7 @@ Phaser.Device.prototype = {
/**
* Check whether the host environment can play audio.
* @method Phaser.Device#canPlayAudio
* @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.
* @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm' or 'opus'.
* @return {boolean} True if the given file type is supported by the browser, otherwise false.
*/
canPlayAudio: function (type) {
@ -893,6 +893,10 @@ Phaser.Device.prototype = {
{
return true;
}
else if (type == 'opus' && this.opus)
{
return true;
}
else if (type == 'wav' && this.wav)
{
return true;