php - Autoplay next embedded soundcloud track? -
i'm using http://ifttt.com grab public favourites soundcloud , post them wordpress site (http://diversesounds.co.uk).
ifttt creates post on site following contents;
<div class="trackurl" id="(ifttt grabs track url , places here)">
i have following block of js;
<script src="//connect.soundcloud.com/sdk.js"></script> <script> <?php if(have_posts()): while (have_posts()) : the_post(); ?> <?php // exploding content track url div id $thecontent = get_the_content(); $explode = explode('"', $thecontent); $trackurl = $explode[3]; ?> sc.oembed( "<?php echo $trackurl; ?>", { color: "494e72", show_comments: false }, document.getelementbyid("<?php echo $trackurl; ?>") ); <?php endwhile; endif; ?>
the above code works autoplay next track after finishing first manually played track.
i know next nothing js (i grabbed code above soundcloud docs please bare me.
thanks - joe
you add listener onmediaend event , try play next track that:
soundcloud.addeventlistener('onmediaend', function(player, data) { // find next player here , use api method api_play() });
docs: http://developers.soundcloud.com/docs/widget#widget-events
you'll need swap out embed method though. js wrapper on github
Comments
Post a Comment