Search code examples
androidcordovahtml5-audiojplayer

JPlayer Starting Position Issue


My Mobile App provides access to a large database of mp3 Audios. The App also allows the user to start an Audio from a specific position (basically last played position).

Whenever I try to run an audio from a given position, it first run the audio from the start for a second and then jumps to the given position.

I have also tried muting the audio but apparently mute also doesn't work after the first instance.

Here is how I am try to do this:

LastAudioPosition = 25;
$(this).jPlayer("play",LastAudioPosition);

Solution

  • After not finding a solution anywhere I ultimately settled with almost perfect solution. The idea is to mute the player for a small duration while the wrong part is played and then unmute it:

    $("#jquery_jplayer_1").jPlayer({
      ready: function () {
        $(this).jPlayer("setMedia", {
        mp3: gsLink
        }).jPlayer("play",gQFA_LastAudioPosition);
      },
      ended: function() {
        endFunction();
      },
      canplay: function() {
        $(this).jPlayer("mute");
        $(this).jPlayer("play");
        $(this).jPlayer("pause");
        $(this).jPlayer("play",gQFA_LastAudioPosition);
        setTimeout(function () {
          $("#jquery_jplayer_1").jPlayer("unmute");
        }, 200);
    },.................