Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6910729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:51:07+00:00 2026-05-27T08:51:07+00:00

I have built a simple tour on my website that will be coded using

  • 0

I have built a simple tour on my website that will be coded using HTML5 animation. It will use sound from the HTML5 audio tag and the tour will be loaded in using jquery.

When the tour is loaded it will start playing the audio and the user can mute the sound by toggling a link. And if they close the tour then the audio is reset!

I have parts of this working but don’t seem to be able to properly toggle the music on and off and then stop it completely if they close the tour. Can anyone help?

var sound;

            $(document).ready(function ()
            {   
                sound = $('#soundTour');

                $('.sound a').click(function()
                {
                    $(this).parents('div').toggleClass('mute');

                    if (sound.paused)
                    {
                        sound.play();
                    }
                    else
                    {
                        sound.pause();
                    }
                });

                $('.showTour').click(function()
                {
                    $('body').addClass('theatre'); $('#tour').fadeIn('slow', function() {  });

                    sound.trigger('play');
                });

                $('#tour').find('.tourClose').click(function()
                {
                    $('body').removeClass('theatre'); $('#tour').fadeOut('slow', function() {  });

                    sound.currentTime=0;
                    sound.pause();

                });

            });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:51:07+00:00Added an answer on May 27, 2026 at 8:51 am

    You are using jQuery’s trigger() to trigger events that are not defined in the posted code, as such it is difficult to really say what ‘stop’ is, but as a general rule HTML5 Audio does not have a stop() function, only play() and pause(), to reset the audio just define the source again or set the .currenttime to zero, like so:

    var audioElm = document.getElementById('soundTour');
        audioElm.src = 'myaudio.mp3';
        audioElm.load();
    

    or

    var audioElm = document.getElementById('soundTour');
        audioElm.currentTime=0;
        audioElm.pause();
    

    Setting currentTime only rewinds the audio to the beginning, and does not really stop it.

    Here’s a fiddle to show one way of doing it.
    It uses a mp3 file so your browser must support that format: http://jsfiddle.net/adeneo/n6Bar/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a simple website monitoring application using Indy TIdhttp component. I want
I have built a very simple CakePHP website using the Auth component and have
I have a simple table view which I have built using an example from
I have built a website using php and simple HTML/CSS for a client. In
I have built a simple rails app with three classes that inherit from ActiveRecord
I have built a simple Eclipse plugin where a user may use a TableViewer
I have built a very simple blog application using Ruby on Rails. New to
Does Python have a built-in, simple way of encoding/decoding strings using a password? Something
We have a simple file browser on our intranet, built using ASP/vbscript. The files
I have built a variety of little scripts using Ruby's very simple Queue class,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.