This class allows callback functions to be triggered at specific time points in an audio or video file. Time points can be defined in seconds or percents. Each callback is triggered only once.
<script src="https://cdn.jsdelivr.net/npm/@thibka/[email protected]/MediaTrigger-es5.min.js"></script>
npm i @thibka/mediatrigger
var mediaTrigger = new MediaTrigger({
media: document.querySelector('video'),
triggers: [
['2.5s', function(){
// ...
}],
['25%', function(){
// ...
}]
]
});
mediaTrigger.start();
// mediaTrigger.stop();