Burgestrand/Hallon — Issue #81: Ability to get Player position
Author: Burgestrand
Created: 2012-02-26 21:41:27+00:00
State: open
Labels: Feature Request

@burgestrand Is it possible to determine the player position using Hallon and hallon-openal? Ex: seconds or percentage of the track played?

— Andrew Grieser (@agrieser) February 26, 2012

To do this one would need to know how many frames have been played since the current track started playing. Only the driver can ever know this value (since it may buffer audio itself), so the counter of how many frames have been played must be the driver’s responsibility.

Now, for the driver to have an accurate counter, it needs to know when a new track starts playing so it can reset the counter. This hints to the Player having some additional non-libspotify events that it may fire.

However, as of current writing, [the driver knows nothing about the Player](https://github.com/Burgestrand/Hallon/blob/2f6993827db99b7ed74cbcbe5c2672b2fbb83f82/lib/hallon/player.rb#L44). In order for it to listen to events, the driver will either need to have access to the Player (passed in via #initialize perhaps), or the Player will need to set the driver up with the events (using #respond_to? to determine if the driver supports these events).