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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:08:46+00:00 2026-05-23T12:08:46+00:00

This is script from an audio player. I got from the Jquery cookbook that

  • 0

This is script from an audio player. I got from the Jquery cookbook that I can’t seem to get working. I’m really stumped and would appreciate any help.

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>


<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-        ui.css" rel="stylesheet" type="text/css"/>
 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js">          </script>
</head>

<body>

<script>


var $audio = $('audio');
console.log($audio);
var audioEl = $audio[0];
console.log(audioEl);
var secondsTotal = audioEl.currentTime;
console.log(secondsTotal);
var audio = {
currentTime: 0,
duration: secondsTotal,
volume: 0.5,
set: function(key, value) {
this[key] = value; 
try { audioEl[key] = value; } catch(e) {}



    if (key != 'currentTime') {
    $audio.trigger('timeupdate');
    }
    if (key != 'volume') {
    $audio.trigger('volumechange');
    }
    },
    play: function() {
    audioEl.play && audioEl.play();
    },
    pause: function() {
    audioEl.pause && audioEl.pause();
    }
    };
    console.log(audio);
    $audio.bind('timeupdate', function() {
    audio.currentTime = audioEl.currentTime;
    });
    audio.set('currentTime', 0);
    audio.set('volume', 0.5);

    //end compatibility layer

    //play pause button


    var $audio = $('audio'), audioEl = $audio[0];
    var audio = {
    currentTime: 0,
    duration: secondsTotal,
    volume: 0.5,
    set: function(key, value) {
    this[key] = value;
    try { audioEl[key] = value; } catch(e) {}
    if (key == 'currentTime') {
    $audio.trigger('timeupdate');
    }
    if (key == 'volume') {
    $audio.trigger('volumechange');
    }
    },
    play: function() {
    audioEl.play && audioEl.play();
    },
    pause: function() {
    audioEl.pause && audioEl.pause();
    }
    };

    $audio.bind('timeupdate', function() {
    audio.currentTime = audioEl.currentTime;
    });
    audio.set('currentTime', 0);
    audio.set('volume', 0.5);

    //end compatibility layer

    //play pause button


    $('.mplayer .playpause').click(function() {
    var player = $(this).parents('.mplayer');
    if (player.is('.paused')) {
    $('.mplayer').removeClass('paused');
    audio.play();
    } else {
    $('.mplayer').addClass('paused');
    audio.pause();
    }
    return false;
    })
    .hover(function() { $(this).addClass('ui-state-hover'); },
    function() { $(this).removeClass('ui-state-hover'); })
    .focus(function() { $(this).addClass('ui-state-focus'); })
    .blur(function() { $(this).removeClass('ui-state-focus'); });
    $('.mplayer').addClass('paused');


    // current and total time labels

    function minAndSec(sec) {
    sec = parseInt(sec);
    return Math.floor(sec / 60) + ":" + (sec % 60 < 10 ? '0' : '') +
    Math.floor(sec % 60);
    }
    $('.mplayer .currenttime').text(minAndSec(audio.currentTime));
    $('.mplayer .duration').text(minAndSec(secondsTotal));
    $audio.bind('timeupdate', function(event) {
    $('.mplayer .currenttime').text(minAndSec(audio.currentTime));
    });

    // slider

    $('.mplayer .track').slider({
    range: 'min',
    max: audio.duration,
    slide: function(event, ui) {
    $('.ui-slider-handle', this).css('margin-left',
    (ui.value < 3) ? (1 - ui.value) + 'px' : '');
    if (ui.value >= 0 && ui.value <= audio.duration) {
    audio.set('currentTime', ui.value);
    }
    },
    change: function(event, ui) {
    $('.ui-slider-handle', this).css('margin-left',
    (ui.value < 3) ? (1 - ui.value) + 'px' : '');
    }
    })
    .find('.ui-slider-handle').css('margin-left', '0').end()
    .find('.ui-slider-range').addClass('ui-corner-left').end();
    $audio.bind('timeupdate', function(event) {
    $('.mplayer .track').bind(function() {
    if ($(this).slider('value') != audio.currentTime) {
    $(this).slider('value', audio.currentTime);
    }
    });
    $('.mplayer .currenttime').text(minAndSec(audio.currentTime));
    });

    //
    var secondsCached = 0, cacheInterval;
    $('.mplayer .track').progressbar({
    value: secondsCached / secondsTotal * 100
    })
    $('.mplayer .track').find('.ui-progressbar-value').css('opacity', 0.2).end();
    cacheInterval = setInterval(function() {
    secondsCached += 2;
    if (secondsCached > secondsTotal) clearInterval(cacheInterval);
    $('.mplayer .track.ui-progressbar').progressbar('value', secondsCached / secondsTotal * 100);
    }, 30);

    //volume control

    $('.mplayer .volume').slider({
    max: 1,
    orientation: 'vertical',
    range: 'min',
    step: 0.01,
    value: audio.volume,
    start: function(event, ui) {
    $(this).addClass('ui-slider-sliding');
    $(this).parents('.ui-slider').css({
    'margin-top': (((1 - audio.volume) * -100) + 5) + 'px',
    'height': '100px'
    }).find('.ui-slider-range').show();
    },
    slide: function(event, ui) {
    if (ui.value >= 0 && ui.value <= 1) {
    audio.set('volume', ui.value);
    }
    $(this).css({
    'margin-top': (((1 - audio.volume) * -100) + 5) + 'px',
    'height': '100px'
    }).find('.ui-slider-range').show();
    },
    stop: function(event, ui) {
    $(this).removeClass('ui-slider-sliding');
    var overHandle = $(event.originalEvent.target)
    .closest('.ui-slider-handle').length > 0;
    if (!overHandle) {
    $(this).css({
    'margin-top': '',
    'height': ''
    }).find('.ui-slider-range').hide();
    }
    },
    change: function(event, ui) {
    if (ui.value >= 0 && ui.value <= 1) {
    if (ui.value != audio.volume) {
    audio.set('volume', ui.value);
    }
    }
    }
    })
    .mouseenter(function(event) {
    if ($('.ui-slider-handle.ui-state-active').length) {
    return;
    }
    $(this).css({
    'margin-top': (((1 - audio.volume) * -100) + 5) + 'px',
    'height': '100px'
    }).find('.ui-slider-range').show();
    })
    .mouseleave(function() {
    $(this).not('.ui-slider-sliding').css({
    'margin-top': '',
    'height': ''
    }).find('.ui-slider-range').hide();
    })
    .find('.ui-slider-range').addClass('ui-corner-bottom').hide().end();





$('.mplayer').each(function() {
$('.bg:first', this).css('opacity', 0.7);
$('.bg:last', this).css('opacity', 0.3);
})
$('.mplayer .rod').css('opacity', 0.4);
$('.mplayer .hl').css('opacity', 0.25);
$('.mplayer .hl2').css('opacity', 0.15);
});

</script>
  • 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-23T12:08:46+00:00Added an answer on May 23, 2026 at 12:08 pm

    You should try setInterval(). setInterval will call a method every certain amount of milliseconds. You can use setInterval to call a method that checks the currentTime of the song playing.

    Example

    setInterval(checkSongTime, 1000);
    
    function checkSongTime(){
    // code to check the current time of the song and to display it
    }
    

    Tip: “1000” is the amount of milliseconds, and it also equals 1 second, therefore your time will be updated once every second.

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

Sidebar

Related Questions

I have this script that collects data from users and I want to check
I have this script: select name,create_date,modify_date from sys.procedures order by modify_date desc I can
This is from a sql script. What tool can generate this? Thanks --USE [MY_TABLE]
I got this script from here . I'm probably staring right at it but
So I call this PHP script from the command line: /usr/bin/php /var/www/bims/index.php projects/output and
I'm trying to modify the code from this script . Basically I'm trying to
I am converting a linux script from http://www.perlmonks.org/index.pl?node_id=217166 specifically this: #!/usr/bin/perl -w use strict;
im using a simple test script from http://www.tuxradar.com/practicalphp/8/11/0 like this <?php $fp = fopen(foo.txt,
I have this PHP script which i'm grabbing images from a directory and displaying
So I wrote this short script (correct word?) to download the comic images from

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.