Forums

Audio playing in background wiith only on/off switch (5 posts)

  1. joaking
    Member
    Posted 9 months ago #

    I am looking for a plug-in or code that enables me to auto-play an audio file in the background of a page. The only option the user should have is to switch the sound on and off or simply pause the music until the button is pressed again.

    Anybody knows about such a plug-in?

    Thanks!

  2. Hichamitooo
    Member
    Posted 8 months ago #

    Same request ? any help, please

  3. noush
    Member
    Posted 6 months ago #

    I'm also looking for something similar ... I managed to add music on home page and mute it when click on an image but don't know how to start the music again when press the same button or may be another ... I added this code in my index.php

    <SPAN style="position:absolute;" ID="soundBlock">
    <embed src="<?php bloginfo('stylesheet_directory'); ?>/music.mp3" loop="true" autostart="true" hidden="true" enablejavascript="true">
    </SPAN>
    <div class="mute"><img src="<?php bloginfo('stylesheet_directory'); ?>/assets/images/Mute.png" onclick="stopBackgroundSound();" ></div>

    and added this script under header.php before <?php wp_head(); ?>...

    <script type="text/javascript">
    function stopBackgroundSound() {
     document.getElementById('soundBlock').innerHTML='';
    }
    </script>

    Any help to play the music back will be much appreciated...

    Thanks

  4. noush
    Member
    Posted 6 months ago #

    I Finally found the solution that worked for me... I pasted this script in Header.php before <?php wp_head(); ?> tag:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    You obviously need to replace the paths and file names according to your requirements...

    The credit goes to jscheuer1 who posted the solution here

  5. lizakwan
    Member
    Posted 2 weeks ago #

    noush, thanks for your tips, I tried and put everything in header.php, it works fine on the main page but not other pages. Do you know why?
    check out here

Reply

You must log in to post.

About this Topic