Skip to content

Commit 5d84f38

Browse files
committed
Device.canPlayAudio now supports the opus files directly, as well as opus encoded audio stored in ogg containers (phaserjs#1232)
1 parent 88a97b9 commit 5d84f38

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Version 2.1.3 - "Ravinda" - in development
8282
* Changed the Animation constructor parameter `delay` to `frameRate` as it's a more accurate term of what it should be. Internally nothing changed.
8383
* Circle.getBounds added.
8484
* Ellipse.getBounds added.
85+
* Device.canPlayAudio now supports the `opus` files directly, as well as `opus` encoded audio stored in ogg containers (#1232)
8586

8687
### Bug Fixes
8788

src/system/Device.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ Phaser.Device.prototype = {
712712
this.ogg = true;
713713
}
714714

715-
if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '')) {
715+
if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) {
716716
this.opus = true;
717717
}
718718

@@ -876,7 +876,7 @@ Phaser.Device.prototype = {
876876
/**
877877
* Check whether the host environment can play audio.
878878
* @method Phaser.Device#canPlayAudio
879-
* @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.
879+
* @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm' or 'opus'.
880880
* @return {boolean} True if the given file type is supported by the browser, otherwise false.
881881
*/
882882
canPlayAudio: function (type) {
@@ -893,6 +893,10 @@ Phaser.Device.prototype = {
893893
{
894894
return true;
895895
}
896+
else if (type == 'opus' && this.opus)
897+
{
898+
return true;
899+
}
896900
else if (type == 'wav' && this.wav)
897901
{
898902
return true;

0 commit comments

Comments
 (0)