I'm using nginx and nginx rtmp module to create audio stream for mobile. For video I use ffmpeg to slice video to jpeg images, and that way I display video stream to mobile users. Audio is going separate which causes audio latency of 15-30 seconds. I assume that this happens because video of jpegs starts before audio buffers. So what I tried is to catch <audio> event "canplay" and when this event fires, then to start the video preview.
Audio source example: http://example.com:8081/hls/audio.m3u8
The code for detection:
var audio = document.getElementById('preview-audio');
audio.oncanplay=function(){ console.log('audio loaded'); };
but this event never fires. Only events that fire are "loadstart" and "progress". How can I detect that audio is buffered so that I can sync it with jpeg's?
Thanks in advance