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

Uncaught TypeError: Cannot read property 'AudioContext' of undefined #65

Open
danielhusar opened this issue Jun 19, 2016 · 4 comments
Open

Comments

@danielhusar
Copy link

I'm getting this issue when installing sdk from npm and using it with webpack and babel.
(webpack ^1.12.12 , babel: ^6.2.1)

@lukephills
Copy link

Hi @danielhusar, this sounds like an error in your code related to how your using web audio not the soundcloud api. I have an example (here) using tone.js which may help you.

Can you share your code?

@caseykolb
Copy link

Unfortunately, I had the same error with the same versions of webpack and babel. It breaks immediately on import, but my app works totally fine with a manual HTML reference to Soundcloud's CDN.

@ProLoser
Copy link

ProLoser commented Aug 1, 2018

I'm having this same problem too, it happens on the first method call:

I don't know why this wouldn't work but it doesn't.

sdk.js:23 Uncaught TypeError: Cannot read property 'AudioContext' of undefined

import SC from 'soundcloud';
import EVENTS from '../Events';

let track = `/tracks/${window.location.search.substr(1)}`;

const SOUNDCLOUD_STATES = {
  'playing': EVENTS.PLAYING,
  'paused': EVENTS.PAUSED,
  'loading': EVENTS.LOADING,
  'ended': EVENTS.COMPLETE,
  'error': EVENTS.ERROR
};

SC.stream(track).then(function(player){
  player.play();


  player.on('state-change', event => {
    window.postMessageNative(SOUNDCLOUD_STATES[event], '*');
  });


  document.addEventListener('message', window.listener = function(event) {
    let data = JSON.parse(event.data);
    switch (data.type) {
      case EVENTS.PLAY:
        player.play();
        break;
      case EVENTS.PAUSE:
        player.pause();
        break;
      case EVENTS.VOLUME:
        player.setVolume(.5);
        break;
    }
  });
});

@Andrewjeska
Copy link

Likewise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants