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