• I’m wondering if the players could be embedded sooner, as to not have to wait for all the sidebar widgets to be built first, as AudioPlayer is more important than many of the widgets that connect to external sources (twitter, facebook, etc.) and manage to take their sweet time doing it.

    I see that that with the current AudioPlayer 2.0.1, the function that embeds the actual player (replacing the textual message about installing/upgrading Flash) doesn’t happen until the footer (several hundred lines down, in my case). It looks like this:

    <script type="text/javascript">
    AudioPlayer.embed("audioplayer_1", {soundFile:"..."});
    AudioPlayer.embed("audioplayer_2", {soundFile:"..."});
    </script>

    Is it possible to run this script any sooner to embed the players sooner? Perhaps in the header or prior to the players (or, at least, before the sidebars load)?

    Thanks in advance for support! Great plugin!

    p.s. The page in question is https://missingtoof.com/?theme=2010
    (using a Theme Test Drive plugin for redesign sandboxing. Append ?theme=2010 to pages to view the project correctly).

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter missingtoof

    (@missingtoof)

    To answer my own question, I just edited audio-player.php. I only had to change one line to get the script to run at the K2 hook ‘template_primary_end’ (I’m using K2, and this will only work if you are using K2 also).

    Before:
    add_action("wp_footer", array(&$this, "addFooterCode"));
    After:
    add_action("template_primary_end", array(&$this, "addFooterCode"));

    Hope that works for someone else having the same issue. I also hope this alteration isn’t stepping on the license terms, I don’t think it is. Perhaps earlier execution will become an option in Audio Player 2.2 or future releases.

    @missingtoof

    Thanks for the tip. I’ll look into adding this as an option. As you said, this can only be achieved with the K2 theme.

    Thanks,

    Martin

    Thread Starter missingtoof

    (@missingtoof)

    Changed it to a different K2 hook which works better on all pages. Anyone using K2 who wants the embed javascript to be called before the sidebars should use the hook ‘template_entry_foot’ instead of ‘template_primary_end’ which I erroneously said above.

    So the alteration is:

    Before:
    add_action("wp_footer", array(&$this, "addFooterCode"));
    After:
    add_action("template_entry_foot", array(&$this, "addFooterCode"));

    Hope that helps. Not sure if there is a hook at the bottom of the entries for default wordpress install (same with Themeatic, etc.).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Audio Player] Can AudioPlayer.embed script be inserted in header instead of footer?’ is closed to new replies.