Note that there are some explanatory texts on larger screens.

plurals
  1. POusing jquery + <audio> w/ php/mysql to loop playback times
    primarykey
    data
    text
    <p>I've got a page with an <code>iframe</code>. The iframe is using <code>jquery.scrollTo</code> to detect the audio playback time and keep the contents, lyrics for example, linked to the right point in the audio.</p> <p>Each line of text is being pulled from a mysql table. What I'm trying to do is to allow the user to click on a line in the <code>&lt;iframe&gt;</code> and have the audio in the parent page play at that point. Here's the code that grabs the times, which exists after the jquery that handles the other audio functions:</p> <pre><code>&lt;?php include 'mysqlt.php'; $entries=mysql_query("SELECT * FROM `database`.`table`") or die(mysql_error()); while ($ent = mysql_fetch_object($entries)) { $segment = $ent-&gt;index; $starttime = $ent-&gt;time; $nextline = $ent-&gt;time2; $length = ($nextline - $starttime); ?&gt; </code></pre> <p>That same information is also duplicated in the <code>iframe</code> source page along with the individual lines of lyrics. The jquery that uses this info follows:</p> <pre><code>$("#iframe_id").contents().find("#button_in_iframe&lt;?php echo $segment;?&gt;").bind("click", function(){ audioplayer.currentTime = &lt;?php echo $time;?&gt;; audioplayer.play(); } &lt;?php } ?&gt; </code></pre> <p>This second part loops, echoed once for each each potential line in the iframe that can be clicked. <code>#button_in_iframe&lt;?php echo $segment;?&gt;</code> ends up as something like <code>#button_in_iframe23</code> for the 23rd line.</p> <p>I've got jquery loaded up in both the parent and the iframe. As far as I can tell, the syntax is what it should be. If I remove this bit of code, everything works normally. if it's in there, the basic audio functions on the normal controls I have set stop working. So this is not only not working, but it's causing everything else associated with the audio tag's controls to stop working as well. I know that any small error in the audio controls' jquery is enough to make it stop working, but in this case I'm not sure where the problem is.</p> <p>Thanks in advance for any insights anyone might be able to offer.</p> <p><strong>update:</strong> I've got it so it no longer crashes the audio tag. Now it's more an issue of the iframe's item not triggering an event. Here's the code now:</p> <pre><code>$('#iframe_id').contents().find("button.loop2").bind("click", function() { alert ("test"); }); </code></pre> <p>I'm not getting any console errors except for a Google Maps imbedded in the page in another location. When i click the <code>&lt;button&gt;</code> with class <code>loop2</code> in the iframe, all of which exist, nothing's happening. That seems to be the root of the problem as it was earlier.</p>
    singulars
    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.
 

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