Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on Safari / Chrome (MacOS) #7

Closed
hiro28 opened this issue Feb 17, 2017 · 10 comments
Closed

Not working on Safari / Chrome (MacOS) #7

hiro28 opened this issue Feb 17, 2017 · 10 comments

Comments

@hiro28
Copy link

hiro28 commented Feb 17, 2017

Here is the console's log

ReferenceError: Can't find variable: AudioContext

screen shot 2017-02-17 at 11 08 56 am

@egoist
Copy link
Contributor

egoist commented Feb 17, 2017

You can add if (typeof AudioContext !== 'undefined') {} in your code, but it would better be fixed in the library itself, many browsers do not support this.

@Okazari
Copy link
Owner

Okazari commented Feb 17, 2017

I probably need to add a polyfill for safari. I will look how i can do this in a clean way. It will also fix #4 thought.

@Okazari
Copy link
Owner

Okazari commented Feb 18, 2017

Just found this : In Safari, the audio context has a prefix of webkit for backward-compatibility reasons. Since the Web Audio API is a work in progress, specification details may change.

I'll go for this fix.

@Okazari
Copy link
Owner

Okazari commented Feb 18, 2017

I just updated the code and the demo, @hiro28 could you try it again on Safari ? If this works, i'll release a v1.2.4 with this patch.

@Okazari
Copy link
Owner

Okazari commented Feb 23, 2017

Someone reported that it didn't work in chrome on Mac too 😱

@Okazari Okazari changed the title Not working on Safari (MacOS) Not working on Safari / Chrome (MacOS) Feb 23, 2017
@Nouvan
Copy link

Nouvan commented Mar 7, 2017

I'm currently debugging your code, since I want this proejct working on mobile phone.
I finaly get the music on mobile safari with this correction :

Line 167 :
this.browserAudioCtx = (typeof AudioContext == "undefined" || AudioContext == null)? window.webkitAudioContext: window.AudioContext;

However, the animations don't work properly. After some research, the main cause is on the analyser itself, but I didn't know the exact cause for the moment.

EDIT : After some research, I found this example which use Audio API
http://codepen.io/anon/pen/dvOYMr?editors=0010

When testing on Safari, it reveal that the function getByteFrequencyData always return an entire array of 0.

@Okazari
Copy link
Owner

Okazari commented Mar 7, 2017

Hey @Nouvan Thanks for the feedback !

The current code is already using this correction https://github.com/Okazari/Rythm.js/blob/master/src/Player.js#L5

It looks like safari will need a polyfill for this functionnality, i'll look in this way.

@Nouvan
Copy link

Nouvan commented Mar 20, 2017

Hi @Okazari !

Did you try https://github.com/mohayonao/web-audio-engine ? Maybe it would be enough to make your project good on IOS devices ;) !

I will try soon and send you the results of my test.

@Okazari Okazari added this to the v2.0.1 - Bugfixes milestone Mar 20, 2017
@Okazari
Copy link
Owner

Okazari commented Mar 20, 2017

Thanks @Nouvan i appreciate.

I actually cannot work on Rythm.js because i got a lot of works and projects to finalize !

Anyway, thanks for the suggestion, i'll take a look. Still need to test if polyfills would be enougth tho.

@Okazari
Copy link
Owner

Okazari commented Sep 5, 2017

throwaway12933428233 on reddit :
Trouble is on this line:
this.browserAudioCtx = AudioContext || webkitAudioContext
If AudioContext is not defined, it throws an error. It doesn't fall back to webkitAudioContext. The script stops.
Easiest fix:
this.browserAudioCtx = window.AudioContext || window.webkitAudioContext

ldd added a commit to ldd/Rythm.js that referenced this issue Sep 5, 2017
@Okazari Okazari closed this as completed in a10b489 Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants