facebook

Question:: How do i get audio to repeat automatically?

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #347999 Reply

    Uplink1001
    Member

    HI.
    On button click audio plays to end, unless i press stop button.
    How do i get it to auto repeat when it has reached the end, without having to press play again.
    On click run javascript:

    if (media2){media2.stop();}
    done = function() {};
    error = function() {};
    status = function(status) {};

    media1 = phoneui.createMedia(‘100bpm.mp3’, done, error, status);
    // then just use Cordova Media API:
    media1.play();

    THanks Uplink1001

    #348000 Reply

    Brandon
    Member

    The audio widget is built off the jPlayer. Here is the docs to loop or repeat:

    http://www.jplayer.org/latest/quick-start-guide/event-ended/

    I had a sample of this in the how-to section, it may or may not work as they have updated the API, though I think it will work with some slight modification. You can search the how-to to find it.

    #348003 Reply

    Code_A
    Member

    I am assuming you are wanting to do this programmatically, which is why you are not using the built-in repeat option for the audio widget.

    Have you tried subscribing to the events to listen for the end? Check out the Consuming Events example in the Audio Widget API documentation. I have not tried this but it looks like it may be a solution.

    Specifically, this snippet:

    var aw1 = AudioPlayerWidget.fromWidget('m1-test-audio1-container');
     
    function onEnd(event) {
        event.player.play();
    }
     
    // subscribe for events
    aw1.events.bind('ended', onEnd);   
    aw1.events.bind('ended paused', function(event) { console.log(event.type); });
     
    // unsubscribe
    aw1.events.unbind('ended', onEnd);
    #348017 Reply

    Uplink1001
    Member

    Hi.
    Thanks to you both, I will give it a try, and get back.

    Thanks
    Uplink1001

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Question:: How do i get audio to repeat automatically?

You must be logged in to post in the forum log in