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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:00:54+00:00 2026-06-01T09:00:54+00:00

For some odd reason the HTML5 Audio API won’t give me access to currentTime

  • 0

For some odd reason the HTML5 Audio API won’t give me access to currentTime in iOS 4 and 5 for iPads and iPods. I need to adjust currentTime whenever an audio element is played, but it acts like the current time isn’t accessible. Looked everywhere for an answer on this and I can’t figure it out. My code below works fine in all modern browsers, so I’m a bit stumped.

My HTML markup

<p>
    <a class="audio" href="assets/audio/ambient-sounds-1.mp3" data-flash="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/niftyplayer.swf" data-mp3="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/ambient-sounds-1.mp3" data-ogg="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/ambient-sounds-1.ogg">
        Ambient Sounds
        <span class="audio-play">Play</span>
        <audio preload="">
            <source preload="" src="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/ambient-sounds-1.mp3" type="audio/mpeg">
            <source preload="" src="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/ambient-sounds-1.ogg" type="audio/ogg">
        </audio>
    </a>
</p>

<p>
    <a class="audio" href="assets/audio/city_street.mp3" data-flash="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/niftyplayer.swf" data-mp3="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/city_street.mp3" data-ogg="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/city_street.ogg">
        City Street Sounds
        <span class="audio-play">Play</span>
        <audio preload="">
            <source preload="" src="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/city_street.mp3" type="audio/mpeg">
            <source preload="" src="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/city_street.ogg" type="audio/ogg">
        </audio>
    </a>
</p>

<p>
    <a class="audio" href="#" data-flash="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/niftyplayer.swf" data-mp3="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/crash.mp3" data-ogg="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/crash.ogg">
        Loud Crash
        <span class="audio-play">Play</span>
        <audio preload="">
            <source preload="" src="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/crash.mp3" type="audio/mpeg">
            <source preload="" src="http://athens.sierrabravo.net/~ablue/plato/videoplayer/assets/audio/crash.ogg" type="audio/ogg">
        </audio>
    </a>
</p>

My JavaScript

AudioPlayer = {
    init: function () {
        var player = this;
        this.audio = $('.audio'); // Save and cache all audio elements so they can be targeted by mass stop()

        player.audio.each( function() {
            // Bind each audio element
            player.bind($(this));
        });
    },

    bind: function (object) {
        var player = this;

        object.bind('touchstart click', function() {

            // get the real DOM element, not the jQuery array
            var audio = $(this).find('audio').get(0);

            if(audio.paused) { // Check if its playing
                player.play(audio);
            }
            else {
                player.stop(audio);
            }

            return false;
        });
    },

    play: function(audio) {
        // Stop all existing audio elements and set them to 0
        this.audio.each( function() {
            var audioOther = $(this).find('audio').get(0);
            audioOther.pause();
        });

        // Play the audio element
        if(audio.currentTime) audio.currentTime = 0;
        audio.play();
    },

    stop: function(audio) {       
        if(audio.currentTime) audio.currentTime = 0;
        audio.play();
    }

};
  • 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-01T09:00:55+00:00Added an answer on June 1, 2026 at 9:00 am

    There is an answer as to why my code doesn’t work, iOS 4 and 5 need the entire audio element to be completely destroyed (terrible solution, but it works). Here is a quick rundown on how to fix my issue if you’ve run into it.

    1. Insert only 1 element into the page (I inserted mine right before the closing tag).
    2. On click to play a new audio element, completely destroy the existing and rebuild it from scratch with the new track you want to play.
    3. Call .play on the audio element and you’ll be good to go.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for some odd reason the text area I have in my site won't accept
For some odd reason Internet Explorer won't run my queries properly. I designed this
For some odd reason my SFML program won't render anything until I mouse over
For some odd reason NSOrderedSet does not appear to be implemented in iOS. Is
For some odd reason the part where objects are shown and hidden in my
For some odd reason, my application likes to break on me when I switch
I need help debugging some odd file behavior in Python. Take the following script
Ok, this is an odd one for some reason. UPDATE is updating fields, but
For some odd reason, the apc file upload status gives me the file size
I have this asp.NET web site that for some odd reason doesn't want to

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.