scottschiller / SoundManager2

A JavaScript Sound API supporting MP3, MPEG4 and HTML5 audio + RTMP, providing reliable cross-browser/platform audio control in as little as 12 KB. BSD licensed.
http://www.schillmania.com/projects/soundmanager2/
Other
4.99k stars 768 forks source link

Update position does not work on Chrome #175

Closed Deiber closed 6 years ago

Deiber commented 7 years ago

Hi everybody. This is my situation

I have implemented soundmanager2 in a Django project, but when I want to go to a specific position, it doesn't work as it should be, I identified that in Chrome the sound is not completely loaded when soundmanager2 is initialized. The following is my debug.

whileplaying: function () { self.updatePlaying.apply(this); this._360data.fps++; console.log(this.id + ': loading ' + this.bytesLoaded + ' / ' + this.bytesTotal); }.

On Firefox works fine, the console output is that

"ui360Sound0: loading 1 / 1"

But for Chrome this is the result

ui360Sound0: loading 0.6932614378124208 / 1 ... and never reach 1, for this reason, when I click on any position of the timeline the player, it is restarted

The audio file is loading like that:

<div class="ui360 ui360-vis" style="background-image: none;"><div class="sm2-360ui"><canvas class="sm2-canvas hi-dpi" width="512" height="512"></canvas> <span class="sm2-360btn sm2-360btn-default"></span> <div class="sm2-timing alignTweak"></div> <div class="sm2-cover"></div></div><a debug="1" href="https://SERVER/media/audio/Thomas_and_Zed_conversation.ogg" class="sm2_link">The first audio</a></div>

Issue

Any idea about what's happening, and how fix it?

Thanks a lot...!

benweidig commented 7 years ago

We had the same issue with non-functional seeking in Chrome.

Chrome is requiring Accept-Ranges: bytes in the HTTP-Repsonse to be able to seek, even if it already downloaded the whole file. So we added it to the response and it's now working again. Beware: You need also to support 206 Partial response on the server side to actually seek without downloading the whole file first.

See this stackoverflow question and answers for more info.

Deiber commented 6 years ago

@benweidig Thanks a lot for your advice, worked perfectly...!