New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 17 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Mar 2014
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

issue 79949

Sign in to add a comment

createMediaElementSource() should work before window.onload

Project Member Reported by, Feb 1 2012 Back to list

Issue description

createMediaSourceElement() only works properly after window.onload.

The attach case illustrates this. As is, no visualization will render because
onLoad(); is being called before window.onload fires. If you uncomment
window.addEventListener('load', onLoad, false); and comment out the next line,
the visualization works properly.
1.5 KB View Download
Blocking: 79949
Status: Assigned

Comment 3 by, Apr 19 2012

I ran into the exact same problem when trying to connect the audio tag to the web audio api.

I was able to create the source before window onload though, look at the console logs in my attached example. Running createMediaSourceElement inside a setTimeout with no delay seems to be enough to make it work.

In your example, this works for me:
//window.addEventListener('load', onLoad, false);
setTimeout(function (){
}, 0);

Using chrome 18.0.1025.163 on OS X.

We shouldn't have to do any of this though, there is definitely still a bug there.

828 bytes View Download
Testing with Chrome 22.0.1191.1 canary, I was also encountering this issue.

The problem seems to stem from attempting to create and/or connect the context *before* the <audio> element's canplay() event has fired.

If I create a new Audio() object, attach a listener to 'canplay' which creates and connects the contexts, and then kick the sound off with play(), I'm able to get visualization data.

Blocking: chromium:79949
Labels: -Feature-Media-Audio Feature-Media
crogers: Any updates here?

Comment 7 by, Feb 21 2013

This is unlikely to be something I can look at soon.  You or Andrew might be able to help out here.
Owner: ----
Status: Available
Project Member

Comment 9 by, Mar 10 2013

Labels: -Area-WebKit -Feature-Media Cr-Content Cr-Internals-Media
Project Member

Comment 10 by, Apr 6 2013

Labels: -Cr-Content Cr-Blink
Labels: -Cr-Internals-Media -Cr-Blink Cr-Internals-Media-Audio Cr-Blink-Audio Needs-Feedback
Status: Unconfirmed
Summary: createMediaElementSource() should work before window.onload (was: createMediaSourceElement() should work before window.onload)
With M33 on Linux, I was unable to repro the original issue today (visualization occurs for me even with the unmodified original post's test html).

Please provide updated repro steps or WontFix this bug.
Status: WontFix
per #11 : this didn't repro on current builds (M33).  Resolving therefore as WontFix.

Comment 13 by Deleted ...@, Aug 11 2014

it still no work on ios and android, cry~~~~
class4@ - could you file a new bug for the problem you're seeing with iOS and Android?
Me neither one nor the other version does not work on Chrome.
@#14 and #15, the original repro no longer shows visualization for *either* window.onload triggering onLoad() or just onLoad() called prior to window.onload, and there are a couple deprecation warnings around prefixed API usages in the repro html (webkitAudioContext, webkitRequestAnimationFrame). I suspect the javascript may be obsolete/broken at this point. If you are seeing, with updated/working javascript, the original issue on any Chrome platform (including iOS or Android), please file a new bug.
The script does not work on the following platforms and versions:
Windows XP and Chrome 42
Android 4.4.2 and Chrome 42

A 64-bit Windows 7. Chrome 31, however, it worked.

Comment 18 by, May 6 2015

Labels: Cr-Blink-WebAudio
It stopped working in Chrome 42 now enforces CORS for MediaElementAudioSource.  The test needs to set the crossOrigin attribute correctly and have the host of the audio file send the correct access headers to allow cross-origin access.

...and no need to change the above program to work properly during the Chrome 42?

Comment 20 by, May 6 2015

Well, either you have to move the sample audio source to the same origin as the script or you have to modify the program to add crossOrigin attribute to the audio tag and also have the website serving the audio file to return the appropriate headers.

I used the existing script and changed the audio source to be on the same site as the script, and program works fine. I hear the audio and see the visualizations.

I'm not addressing the onload issue, just that the script no longer works on Chrome 42.

Comment 21 by, May 6 2015

What should be entered in the event Icecast2 audio sources for modify the program to add crossOrigin attribute to the audio tag???

Comment 23 by, May 6 2015

I think you should read the CORS specs to figure this out; this isn't really the place for help.  If you think that chrome has a bug with CORS and MediaElementAudioSource, please file a new bug and CC me.
so if you change the audio source:
<audio id="voice" src="" type="audio/mpeg" crossorigin="anonymous" controls autoplay></audio>

then I hear the audio and not see the visualizations.

Comment 25 by, May 6 2015

This works for me; I hear the audio and see the visualizations.  This doesn't seem relevant to this bug. Please file a new one and assign it to me (and make sure you add the label Cr-Blink-WebAudio)
"If you uncomment
window.addEventListener('load', onLoad, false); and comment out the next line,
the visualization works properly."

neither the first nor the second method does not work: there is audio, there is no visualization.

1.9 KB View Download

Comment 27 by, May 7 2015

Chrome complains about the <relay> inside the <script> block in Cr-Blink-WebAudio.html.  If I comment out the <relay> block, then Cr-Blink-WebAudio.html works fine. I hear the audio and see the visualizations using both Chrome 43 and chromium ToT.
Ok thanx.
Other: The Android Chrome when it makes the WebAudio support?
(sound plays fine, but there is no analyser)

Comment 29 by, May 8 2015

So it is working for you now?

About Android, this is a known issue.  Audio is not correctly passed from an audio tag to a MediaElementAudioSource node. It is being worked on, but it is a large change.
The Microsoft Windows version, everything is fine.
Thank you for your help.
Components: -Blink>Audio Blink>Media>Audio

Sign in to add a comment