Dynamic generated contents with soundcloud-custom-player (sc-player.js) and weird streams acting weird

107 views
Skip to first unread message

Iamnevyn

unread,
Jul 16, 2010, 6:41:05 AM7/16/10
to SoundCloudAPI
I'm using the soundcloud custom player, made by you in a project im
trying to make into reality as i am writing this. Instead of using
static links to transform my a href's into custom-players. I add songs
by using json from your tracks api.

Making songs being transformed into custom-players on the run, while
the json-list is getting parsed.

I've managed to everything to transform awsomly well, however there is
still something that twists my mind.

The first time i search for a genre, parsing the json, everything
works well, everything gets parsed, and everything plays like it
should.

But when i yet again search for a new genre in the same session,
parsing the json everything gets parsed and shown. Here comes the
wierd part, the newly parsed data still has the stream from the
previous search-result.

Meaning the previous search and parsed streams, still remains
somewhere.

It does sound like an array is not getting updated somewhere, i'll
look for it, but some extra help from you would be awsome!

Oh and i'm using:

$.ajax(
{
type: "GET",
url: "js/sc-player.js",
dataType: "script"
});

when the json has gotten parsed, to re-load the custom-player into the
active page.

Kind Regards

Joakim

Matas Petrikas

unread,
Jul 16, 2010, 6:57:16 AM7/16/10
to soundc...@googlegroups.com
hi Joakim,

it seems you have some problems with initializing the sc-player.

I'd recommend you embed the script file statically, like in our example, also right after it you can disable the auto init by:

$.fn.scPlayer.defaults.onDomReady = null;

then, after you get the tracks from our api search, generate the link nodes in your dom, where you want your players to be (like you probably do now)
so you got something like that in your html dom:

<a href="http://soundcloud.com/matas/hobnotropic" class="sc-player">Track 1</a>
<a href="http://soundcloud.com/etc.." class="sc-player">Track 2</a>

and then convert these links to players:
$('a.sc-player').scPlayer();

so you don't need to reload the sc-player.js anymore.

also before replacing the existing players you might want to stop the currently playing player:
$('.sc-player.playing a.sc-pause').click();

I hope I could help you, if not, let me know more about you code flow.

greets from Berlin,
Matas


--
You received this message because you are subscribed to the Google Groups "SoundCloudAPI" group.
To post to this group, send email to soundc...@googlegroups.com.
To unsubscribe from this group, send email to soundcloudap...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/soundcloudapi?hl=en.




--
Matas Petrikas
Web Developer, SoundCloud

Mail: ma...@soundcloud.com
Skype: matas.petrikas
Phone: +49 176 787 65 222
Fax: +49 30 8187 8724
http://soundcloud.com/matas
Rosenthaler Straße 13
10119 Berlin
Germany

What is SoundCloud?
http://soundcloud.com/tour

Send me a track?
http://soundcloud.com/matas/dropbox

Iamnevyn

unread,
Jul 16, 2010, 7:38:07 AM7/16/10
to SoundCloudAPI
Awsome! I knew their had to be a better way than loading the
javascript each time!

Thanks for explaning things for a newbie :)

Kind Regards

Joakim
> > soundcloudap...@googlegroups.com<soundcloudapi%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/soundcloudapi?hl=en.
>
> --
> Matas Petrikas
> Web Developer, SoundCloud
>
> Mail: ma...@soundcloud.com
> Skype: matas.petrikas
> Phone: +49 176 787 65 222
> Fax: +49 30 8187 8724http://soundcloud.com/matas
Reply all
Reply to author
Forward
0 new messages