soundcloud / Widget-JS-API

This is the official SoundCloud Widget Javascript API
http://soundcloud.com
149 stars 76 forks source link

Incompatibility error with Facebook JS SDK #4

Open dgrant85 opened 12 years ago

dgrant85 commented 12 years ago

Inclusion of both the Soundcloud HTML5 Widget JS API and Facebook JS SDK results in error:

"Uncaught TypeError: Cannot read property 'method' of undefined" api.js:1

points in unminified source to line 36:

b = y(a.source), d = c.method, e = c.value, d === i.READY && (b ? (b.isReady = !0, C(b, k), v(k, b)) : m.push(a.source));

Attempts for async loading of the API have failed to resolve the bug.

cereallarceny commented 11 years ago

I'm experiencing the exact same problem.

Cahl-Dee commented 11 years ago

As was I, I found the solution here: http://stackoverflow.com/questions/11076148/soundcloud-html5-api-not-working-with-facebook-js?rq=1

What are the chances we can see this fixed in the next version of the API? A dark theme would be appreciated as well :-)

mrcoles commented 11 years ago

+1

wiemann commented 11 years ago

+1

guillaumek commented 11 years ago

+1

Cahl-Dee commented 11 years ago

Have others found that the solution I provided breaks the ability to read soundcloud api messages? I noticed this when I was trying to bind to widget events. I'm not sure if the solution I used worked once and I just didn't notice that I wasn't receiving the soundcloud messages or what, but you will need to make a slightly different alteration than the one mentioned at the stackoverflow link. The origin of the soundcloud api messages in my case is https://w.soundcloud.com not http. I'm not sure if the messages could come from both, so my solution is as follows:

   function parseMessage(a) {
        var b, c, d, e;
        // the below conditional avoids interference between the soundcloud and facebook apis
        if(a.origin == 'https://w.soundcloud.com' || a.origin == 'https://w.soundcloud.com'){
            //console.log("origin = " + a.origin);  // used to find origin
            try {
                c = JSON.parse(a.data)
            } catch (f) {
                console.log(f);
            }

            b = y(a.source);
            d = c.method;
            e = c.value;
            d === i.READY && (b ? (b.isReady = !0, C(b, k), v(k, b)) : m.push(a.source));
            if (!b || a.origin !== b.domain) return !1;
            var g = [];
            e !== undefined && g.push(e), C(b, d, g)
        }
    }
damassi commented 11 years ago

+1