Custom Player - How do I pause and unpause via external event?

269 views
Skip to first unread message

Marc Kremers

unread,
Mar 10, 2011, 2:29:53 PM3/10/11
to SoundCloudAPI
Hi there

Here is my site in progress, not complete yet.
http://marckremers.com/2011

Some of the videos that will play on the same page as the soundcloud
widget has audio.

If the soundcloud custom player is playing, I need to pause the
soundcloud player.. IF it's on though, else the user will experience
audio soup (video sound plus soundcloud). AND resume play of the
soundcloud player if the user clicks out of the video.

I controlling all these things in my jquery.private.js file. I'm using
api with Vimeo for example and I can just say something like this in
my jquery file:

$(this).find('iframe').get(0).api("api_play");
$(this).find('iframe').get(0).api("api_pause");


So I'm looking for that kind of logic for the Soundcloud custom
player. I tried searching around but it's so undocumented still.

Would be extremely grateful if anyone could give me some pointers.
Ideally a [fade in play] / [fade out pause] would be even better (like
the iPhone) but if athat's hassle i'm happy with it just pausing for
now :)

Best,
Marc


Matas Petrikas

unread,
Mar 11, 2011, 4:15:02 AM3/11/11
to soundc...@googlegroups.com, Marc Kremers
hi Marc,

you could simulate a click on the pause button with:

$('.sc-player.playing a.sc-pause').click()

and to start playing again:
$('.sc-player a.sc-play').click()

greets,
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.





Marc Kremers

unread,
Mar 11, 2011, 11:24:01 AM3/11/11
to SoundCloudAPI
Hi Matas,
Thanks for your help again.

It works as it should, but no matter what dI o, I cant make the pause
button talk to my scripts.

Say the player is playing, I press pause, then watch a vimeo, when I
stop watching the vimeo, the player goes back to playing even though
it was paused.

I'm doing soemting like

if(sc_playing == "1"){
$('.sc-player a.sc-play').click();
}

I can get it to work until the point where someone presses pause.
I need to somehow make it that if the user presses pause physically on
the player, it change sc_playing to 0.
I've tried to do this in sc-player.js like so:


$('a.sc-pause').live('click', function(event) {
sc_playing = "0";
});

But it's just not working.

I obviously just dont understand how scope works with variables, I've
tried it in every level but it just doesn't see that i've turned the
variable to 0.

Best
Marc


On Mar 11, 9:15 am, Matas Petrikas <matas.petri...@gmail.com> wrote:
> hi Marc,
>
> you could simulate a click on the pause button with:
>
> $('.sc-player.playing a.sc-pause').click()
>
> and to start playing again:
> $('.sc-player a.sc-play').click()
>
> greets,
> Matas
>

Matas Petrikas

unread,
Mar 14, 2011, 9:19:05 AM3/14/11
to soundc...@googlegroups.com, Marc Kremers
hi Marc,
you don't need to set extra variable for the player status.
It already has a class 'playing' if it's playing, so if you call this:

$('.sc-player.playing a.sc-pause').click();

it'll click pause in the currently playing player.

if you want to remember which one was playing you can add some class to it:
$('.sc-player.playing).addClass('paused').find('a.sc-pause').click();

and then later re-activate it by:
$('.sc-player.paused').removeClass('paused').find('a.sc-play').click();

greets,
Matas
--
Matas Petrikas



Reply all
Reply to author
Forward
0 new messages