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 8693697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:36:14+00:00 2026-06-13T00:36:14+00:00

I have the following code to play audio on my website. The problem is

  • 0

I have the following code to play audio on my website. The problem is playing audio does not stop or pause to play a new one. All the files are playing together like crazy.

$().ready(function () {
    PlayMp3('sounds/file1.mp3');
    PlayMp3('sounds/file2.mp3');
    PlayMp3('sounds/file3.mp3');
    PlayMp3('sounds/file4.mp3');
});
    function PlayMp3(file) {
            var isiPad = navigator.userAgent.match(/iPad/i) != null;
            var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
            var isiPod = navigator.userAgent.match(/iPod/i) != null;
            pauseAllAudio();

            if (navigator.userAgent.indexOf("Firefox") != -1) {
                file = file.replace("mp3", "ogg");            
                $('#content').append('<audio src="' + file + '" controls preload="auto" autobuffer autoplay="autoplay" style="display:none"></audio>');
            }
            else if (isiPad || isiPhone || isiPod) {           
                var snd = new Audio(file);
                snd.load();
                snd.play();            
            }
            else {
                $('#content').append('<embed height="0" width="0" src="' + file + '">');
            }


        }

        function pauseAllAudio() {
            $('video, audio').each(function () {
                $(this)[0].pause();
            });
            var allAudioEls = $('audio');
            allAudioEls.each(function () {
                var a = $(this).get(0);
                a.pause();
            });

            $('audio').remove();
            if (snd != undefined) {
                snd.pause();
            }
        }

This is not a duplicate question. I have tried all solutions from similar questions here and none of the solutions works for me. Thanks.

  • 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-06-13T00:36:15+00:00Added an answer on June 13, 2026 at 12:36 am

    Thanks to Praveen Kumar. Without him, I couldn’t have found the problem to remove ’embed’. After adding $('embed').remove(); to function pauseAllAudio(). It solves for all browsers but Firefox. That firefox doesn’t like mp3 or <embed> tag. I had to do some more research to make it work for only that browser.

    jPlayer looks great and it solves my problem. The solution is as follow.

     function PlayMp3(file) {
        $('embed').remove();
        if (navigator.userAgent.indexOf("Firefox") != -1) {
                file = file.replace("mp3", "ogg");
                $('#jquery_jplayer').jPlayer("pauseOthers");
                $('#jquery_jplayer').jPlayer("setMedia", { oga: file });
                $('#jquery_jplayer').jPlayer("play");
        }
        else {
            $('#content').append('<embed height="0" width="0" src="' + file + '">');
    }
    

    I had to give up on HTML 5 <audio> tag. 🙁

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

Sidebar

Related Questions

I use the following code to record audio files and play. I have a
I have following code to play small audio files private void playVoice() { if
I am using the following code to play audio file. I have tested the
I have the following code for Android which works fine to play a sound
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have the following code: AssetFileDescriptor afd = getAssets().openFd(AudioFile.mp3); player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor());
I'm new in Android development and I have the next question/problem. I'm playing around
I have the following piece of code which play the flv file, <embed align=middle
I have a problem where I can play an audio file if it is
I have the following code: string Keys = string.Join(,,FormValues.AllKeys); I was trying to play

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.