Note that there are some explanatory texts on larger screens.

plurals
  1. POStopping a dynamically created Soundcloud oEmbed player when closing a modal
    primarykey
    data
    text
    <p>I am working on a webapp that allows people to share links from Soundcloud by copying and pasting the URL. Then the webapp generates a running list of people, allowing users to open a modal that loads the a Soundcloud player (via SC.oEmbed). The URL is derived from the element that opens up the modal. So SC.oEmbed opens up the URL found within the href attribute. </p> <p>I have everything working great, except that when the modal is closed the music keeps playing. </p> <p>There doesn't seem to be a stop() or pause() function associated with this player like there is with the Widget player. The only solution I have found is upon close to have SC.oEmbed open up another random soundcloud link but with auto_play off. This works but seems really inelegant and a waste of resources. There must be a better way no? Oh, and I'm using Twitter Bootstrap too. </p> <p>Here's my jQuery code:</p> <pre><code>$(document).ready( function() { SC.initialize({ client_id: "xxxxxxxxxxxxxxxxxx", }); $("a[data-target='#myModal']").click(function(event) { event.preventDefault(); /* makes sure &lt;a&gt; link doesn't actually open new window */ var url = this.href; // gets Soundcloud URL from href in &lt;a&gt; element SC.oEmbed(url, { auto_play: false }, document.getElementById("audio_1_body")); }); /* this part below is what I want to improve -- loading up a random track, just to stop playing of track that was loaded in the modal */ $("#myModal").on("hidden.bs.modal", function(){ url = "https://soundcloud.com/the-deep-dark-woods/sugar-mama-1"; SC.oEmbed(url, { auto_play: false }, document.getElementById("audio_1_body")); //this last part is what I want to improve }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload