readium-shared-js icon indicating copy to clipboard operation
readium-shared-js copied to clipboard

Play audiobook, Firefox and Safari

Open tmoreno opened this issue 9 years ago • 2 comments

This issue is a Bug

Expected Behaviour

I want to continue listening an audiobook when open it a second time, in the page same that I was reading.

Observed behaviour

In audio_player.js file this condition is always false:

if ((notRetry || event.data.seekRetries >= 0) && diff >= 1)

because diff is greater than 1 always.

diff is calculated:

var curTime = _audioElement.currentTime;
var diff = Math.abs(event.data.newCurrentTime - curTime);

_audioElement.currentTime is set to the correct value at the begining but somewhat his value is changed for another value less than the original value, and I don't know why.

Test file(s)

You can test with Moby Dick epub.

Additional information

  • This issue occur in my custom reader but using readium-js lib, build from master.
  • Only occurs in Safari (10), Firefox (49) and mobile browsers. Only works fine on Chrome (53)

tmoreno avatar Oct 10 '16 08:10 tmoreno

The HTML5 audio element used by the Media Overlays player is instantiated from scratch every time a HTML document (spine item) is loaded. The "seek" routine implemented in audio_player.js aims to ensure audio buffers are prefetched before time re-positioning is attempted. That's the difficult part to get right across platforms, because of discrepancies in their respective media backbends and HTML5 audio implementations.

Are you experiencing these issues with the local HTTP server, or a "proper" remote one? (caching policies are different) Also, do you have the web inspector / web console open during your tests? (again, this affects caching)

danielweck avatar Oct 10 '16 08:10 danielweck

At the moment I'm working in my local Express server.

This is the response from the server:

HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type,X-Requested-With,Content-Id, token
Access-Control-Expose-Headers: Content-Type,X-Content
Access-Control-Allow-Methods: GET,POST,PUT,HEAD,DELETE,OPTIONS
Content-Type: audio/mpeg
Cache-Control: max-age=604800, private
Accept-Ranges: bytes
Connection: keep-alive
Content-Length: 10545449
Etag: "-194572868"
Date: Mon, 10 Oct 2016 08:58:36 GMT

tmoreno avatar Oct 10 '16 09:10 tmoreno