2

In accordance with caniuse site, Opera supports audio tag. In accordance with w3schools, mp3 is also supported by Opera. But this code doesn't work. Even the sample from w3schools doesn't work, if ogg part is removed -

<audio controls>
  <source src="horse.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

I've tested it with Opera 20.0.1387.77 running on Windows 7 64-bit (WoW64) thru Spoon.net. And, if it is not supported, then how should I capture the error and inform user? I've tried to use $("#audio").error.code, but the error is null.

LA_
  • 19,823
  • 58
  • 172
  • 308
  • 5
    Are you aware of [how bad reputation w3schools has](http://www.w3fools.com/)? You shouldn't use it for reference, there are MDN and WebPlatform for that. – Pavlo Feb 02 '15 at 16:26
  • @Pavlo, WebPlatform also says that Opera supports `audio` tag, but says nothing about mp3/ogg - https://docs.webplatform.org/wiki/html/elements/audio – LA_ Feb 02 '15 at 16:43
  • 1
    [According to HTML5Test](https://html5test.com/compare/feature/audio-mp3.html#row-desktop-opera-26), Opera supports MP3 audio since version 26. – Pavlo Feb 02 '15 at 16:56
  • A little bit off topic, but I am surprised to what has happened with StackOverflow - almost each my question is downvoted. Who has downvoted it, please clarify why. – LA_ Feb 02 '15 at 17:53

3 Answers3

5

The Test:

After running this JSFiddle through different OS and Opera version configurations on BrowserStack, taking into account the switch from Presto to WebKit, I have come up with the following compatibility information.


Opera MP3 Compatibility:

List items are listed, version numbers, .canPlayType('audio/mpeg;') return value, and actual success/failure to play the audio file.

Windows 8 and 8.1:

  • 25-27: "probably", success
  • Opera <= 24: "", fail

Windows 7:

  • Opera 27: "probably", fail
  • Opera <= 26: "", fail

Windows XP:

  • Opera <= 27: "", fail

OS X 10.10 and 10.9:

  • Opera 26-27: "probably", success
  • Opera <= 25: "", fail

OS X 10.8 and 10.7:

  • Opera <= 27: "", fail

OS X 10.6:

  • Opera <= 25: "", fail

Opera 27 on Windows 7 returning "probably" but failing to play is rather unfortunate.


Conclusion:

From this information, it would appear that Opera does not itself contain the necessary codices to decode MP3 audio files, and it can only do so if the host OS provides a compatible library. It's possible that an Opera user may have the necessary libraries to play an MP3, but there is no guarantee.

Community
  • 1
  • 1
Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
2

When Opera moved to using Webkit as a rendering engine, they dropped native mp3 (and H.264) support, see this blog post: https://dev.opera.com/blog/300-million-users-and-move-to-webkit/ - the information on W3Schools is out of date and likely from the pre-webkit days (PSA: never visit W3Schools).

To check what type of audio you can play, you can use the canPlayType method, like this:

var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));

Source: http://diveintohtml5.info/everything.html

There are a bunch of other methods for doing this sort of detection, which you can see on this question: How to detect HTML5 audio MP3 support

Edit: This may be a version issue - concrete information is pretty thin but I just installed the latest version of Opera (27, OSX) and I can play Mp3's back just fine.

Community
  • 1
  • 1
Dan Smith
  • 5,685
  • 32
  • 33
1

Opera does at least advertise to support mp3, canPlayType("audio/mpeg") returns "probably" and the above script from Bulk does return true but in fact it doesn't support it (it silently fails). This is on a fresh Windows 7 installation without any codec packs and the newest Opera.

Lorenz
  • 2,179
  • 3
  • 19
  • 18