Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play audio between points A and B

How to set From and To Timestamp markers and play media between these two points of an audio file? I don't see listener API for MediaPlayer in Android. Wondering how I can go about achieving this?

My situation is like this: Break audio file into many such parts and let user interactively play/replay select portions of it as he wishes.

For instance, let's assume a small audio file is broken into 3 parts (A---B---C---D), namely, AB, BC, and CD. The user selects part BC and opts to play. The audio then plays starting from point B and stops when it reaches point C. The user may play again part BC or choose to move on to the next part.

While its easier to decide to figure out the starting point and use mediaPlayer.seekTo(int) API, how is it that I can make the audio stop at the end point? What is the best way forward for this?

Your help is much appreciated.

like image 814
karthiks Avatar asked Aug 30 '16 07:08

karthiks


People also ask

Can I play audio in HTML5?

HTML5 features include native audio and video support without the need for Flash. The HTML5 <audio> and <video> tags make it simple to add media to a website. You need to set src attribute to identify the media source and include a controls attribute so the user can play and pause the media.

What does code control do audio?

The controls attribute adds audio controls, like play, pause, and volume. The <source> element allows you to specify alternative audio files which the browser may choose from.

How do I embed audio in an HTML document?

To embed audio in HTML, we use the <audio> tag. Before HTML5, audio cannot be added to web pages in the Internet Explorer era. To play audio, we used web plugins like Flash. After the release of HTML5, it is possible.

How do I make a custom HTML audio tag?

HTML 5 audio tags can be styled. By using the audio tag with “controls” attribute, the default browsers player is used. You can customize by not using the browsers controls. You can also add CSS classes to each one of the elements and style them accordingly.


1 Answers

I think you can use mediaPlayer.seekTo(int msec)

mediaPlayer.setLooping(true); 
mediaPlayer.seekTo(0); 
mediaPlayer.start(); 
like image 68
Jame Avatar answered Sep 22 '22 06:09

Jame