2
I’m working on an HTML 5 player and had a sad surprise when I tried to use the forward/backward feature when I put the cursor in a given minute of the song (as we do on youtube, for example).
<audio id="AudioApresentacao" controls="controls" preload="none">
<source id="urlAudio" type="audio/mpeg" src="ARQUIVO DE AUDIO" /></audio>
It turns out that when you put in a few minutes of audio, like a song, it works normally. But the audio I’m loading has about 80 minutes! And this feature does not work. Someone knows a solution for this?
Tested in Chrome and IE11.
Hello James! Welcome to Soept. Could you be clearer when saying "it doesn’t work", and specify which browsers you found the problem with? It would also be nice to post the code part of your player that you believe is in trouble.
– Fabrício Matté
Hello! Thank you for the welcome! @Fabríciomatté tested on Chrome and IE. What I meant by "it doesn’t work" is that by placing the cursor at a given minute of the song (as we do on youtube, for example) it doesn’t work/back to the point I want.
– tiagopotencia
Always prefer to make your question clearer through editing. http://meta.pt.stackoverflow.com/questions/700/como-comecar-aqui-no-stackoverflow-em-portugues
– Maniero
@edited mustache! Thanks for the tip!
– tiagopotencia
Just a guess: It might have something to do with the file size and the browser still downloading it. Did you try it locally? (maybe he streams even if he’s local)
– Guilherme Bernal
One solution is to divide the file into several smaller ones, and put them to play in sequence, making a custom seekbar with total audio time, being calculating the position that is which of the files should be used. So your browser can stop downloading part of the music and starts loading the other part needed for the position you want.
– Gabriel Gartz
@Gabrielgartz I think this has already been implemented by most browsers: Partial Content. The problem is: does the server support this? If "AUDIO FILE === download.php" or something like that, here’s the problem.
– Gustavo Rodrigues
I also read online that several Apis that manipulate audio files are having problems with memory limits, but in this case I think it’s because they convert the MP3 file into a blob to be able to manipulate local and then consume memory, already on large files the last report was Chrome 13 that was crashing, otherwise I agree with you @Gustavorodrigues, if the server does not support partial download has to make an alternative solution, or wait for the full download of the file.
– Gabriel Gartz
I only saw this when the file needed to be manipulated (Webaudio) or when the API was a codec made in javascript (http://audiocogs.org/codecs/mp3/). In most cases I have already touched them they only use <audio> and/or flash tags: the most technical part is in charge of the browser (or flash).
– Gustavo Rodrigues