Skip to content

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

Open

Description

@danielhusar

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)

Activity

  1. lukephills commented on Jun 23, 2016

    @lukephills

    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?

  2. caseykolb commented on Jul 6, 2016

    @caseykolb

    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.

  3. ProLoser commented on Aug 1, 2018

    @ProLoser

    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;
        }
      });
    });
  4. Andrewjeska commented on Mar 23, 2021

    @Andrewjeska

    Likewise

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions