Giter Site home page Giter Site logo

adamcik / media-progress-timer Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 2.0 48 KB

JS helper designed for accurate tracking of remote playback position in media applications

Home Page: http://adamcik.github.io/media-progress-timer/

License: Apache License 2.0

JavaScript 43.24% HTML 56.76%

media-progress-timer's People

Contributors

adamcik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

media-progress-timer's Issues

Request: expose time function to make testing easier

var now = typeof window.performance !== 'undefined' &&
typeof window.performance.now !== 'undefined' &&
window.performance.now.bind(window.performance) || Date.now ||
function() { return new Date().getTime(); };
makes it a little difficult to write tests that make use of the media progress timer.

Sinon does not currently support faking window.performance - sinonjs/sinon#803. So relying on Date().getTime() would be preferable from a testing perspective, but because now is a private function that is initialised when the module is loaded, it is not possible to add a stub or monkey patch at this stage.

Timer 'dies' unexpectedly if position exceeds duration

I'm using the timer in the Mopidy-Musicbox-Webclient project, and have encountered a situation where the timer appears to 'die' unexpectedly. Steps to reproduce:

  1. timer is started and appears to function normally.
  2. move browser window to the background for several minutes (at least one or two track changes) so that the window / tab does not have focus and is not updated.
  3. switch back to the browser window / tab. The timer no longer updates an appears to be 'stuck'.

Debugging the Javascript, it appears as if ProgressTimer.prototype._update is no longer being called, so the callback is never executed either. I've encountered this issue with the latest versions of Safari and Firefox.

Could it be that window.requestAnimationFrame stops being invoked by the browser at some point or am I misunderstanding how the timer works? I haven't tried the disableRequestAnimationFrame fallback yet as I would ideally like to make use of the lower CPU-load approach offered by the standard options.

Consider changing default updateRate

The default does not at all work well with requestAnimationFrame, likely we want to consider just disabling the update rate for the requestAnimationFrame code path and then renaming it to fallbackUpdateRate or something like that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.