facebook

Playing audio for a definite time

  1. MobiOne Archive
  2.  > 
  3. App Showcase, Stories, Discussions
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #351640 Reply

    pratiti
    Member

    Hello,

    I want to play audio from Audio Widget for a pre defined time, as soon as the time is over the audio should stop playing.
    What to do?

    #351645 Reply

    Code_A
    Member

    There are a couple ways that you could achieve this.

    1) If the pre-defined time is always the same then you could trim your audio file to be the desired length and just play it once (i.e., disable loop or repeat feature)

    2) If the defined time will change in the app, then you will need to setup a JS timer to start/stop the media file.
    Here is a quick outline of the code to give you an idea of how it would look (code below is untested and incomplete)

    media.play()
    setTimeout(function(){                
    media.stop()
    media.release()
    },<duration in ms>);

    Here is the Audio Widget Documentation

    #351647 Reply

    pratiti
    Member

    Thanks, worked perfectly.!

    #351649 Reply

    pratiti
    Member

    If I have 4 audio widgets, and I’ve defined same event function for all of them.
    How can I detect the active audio widget, due to which event function has been called?

    #351652 Reply

    Code_A
    Member

    If you just need to access the the active audio player then try using:

    AudioPlayerWidget.active
    #351664 Reply

    pratiti
    Member

    Thanks.

    #353249 Reply

    bernald
    Member

    Hi Code A,I accept your post.I hope you are well versed in audio player information…Can you suggest which player is good for audio???I will come back shortly..Keep in touch with us..Thanks in Advance..

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Playing audio for a definite time

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