Skip to content

Supporting browser builtin implementation of AudioClip again#56

Merged
jtulach merged 4 commits into
apache:masterfrom
jtulach:AudioIsSupported
May 15, 2026
Merged

Supporting browser builtin implementation of AudioClip again#56
jtulach merged 4 commits into
apache:masterfrom
jtulach:AudioIsSupported

Conversation

@jtulach
Copy link
Copy Markdown
Contributor

@jtulach jtulach commented May 15, 2026

@jtulach jtulach force-pushed the AudioIsSupported branch from e20b14e to 89283c2 Compare May 15, 2026 06:30
@jtulach jtulach changed the title Audio is supported Supporting browser builtin implementation of AudioClip again May 15, 2026
@Override
@JavaScriptBody(args = { "src" }, body = ""
+ "if (typeof Audio !== 'object') return null;"
+ "return new Audio(src);")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • in 2013 I had to distinguish among old JDK7 JavaFX WebView without Audio
  • and newer WebViews (JDK8+) that had Audio object
  • or real browsers that had Audio too
  • at that time the typeof Audio was object
  • these days it is function
    • inspite of calling Audio("some.mp3") yields and error suggesting to use new Audio(...) instead!
  • I know the https://github.com/jtulach/minesweeper was playing its sounds in the past
  • there must have been an incompatible change in the browsers since then
  • that changed the typeof Audio
  • interesting way to break someone's code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me: I do remember that in 2013 the typeof Audio was object. When did it change?

AI: ... there was a major architectural transition across all major browsers that changed web API constructors like Audio, Image, and Option from returning "object" to "function" under the typeof operator.

  • Bug 829524 - DOM constructors should be typeof "function".
  • Bug 83849 - Make DOM constructors have typeof 'function'

I haven't found those bugs/commits, but the explanation matches my memories.

@jtulach jtulach merged commit 0fdc81b into apache:master May 15, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant