Save playback position - #926
Conversation
a714de7 to
6747e79
Compare
cjcolvar
left a comment
There was a problem hiding this comment.
This is really neat and I'm excited to have this feature in Avalon!
This looks great for single canvas manifests but it seems like it isn't resuming playback when the save position is on a canvas other than the first. For example, if I listen to https://media.dlib.indiana.edu/media_objects/tm70nc75d/manifest.json, which has two audio files, and stop playback at 20 seconds into the 2nd section and reload ramp with the manifest then ramp starts at 0 on the first canvas. I'd expect ramp to know that the saved playback position for the manifest is on the 2nd canvas at 20sec and offer to resume me there. This would be especially useful in a many sectioned item like https://media.dlib.indiana.edu/media_objects/nk322d54j.
Seeing that the local storage holds a canvas id -> playback position map, I'm wondering if this would need to be manifest id -> canvas id + playback position or if it is helpful to have two maps manifest id -> canvas id and canvas id -> playback position. It is theoretically possible for a canvas to exist in more than one manifest and it seems like it could be helpful to resume playback regardless of the manifest. But that is probably too much of an edge case to make the extra complexity worth it.
Does this make sense and seem feasible?
|
Yes, that sounds great. It would provide a more user-friendly meaningful user experience for this feature. I think it should be possible to change the storage to provide this solution. And it would probably reduce the number of cached entries in the |
e7f4419 to
33d35fe
Compare
…tion or class' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
cjcolvar
left a comment
There was a problem hiding this comment.
This looks great! I'm excited to see this make it to production!
Not within scope of this PR, but I had a couple thoughts that I wonder might be future improvements if user testing agrees:
- For video items, seek to resume time and make modal semi-transparent to allow for some visual help when answering the question do I want to resume here
- For cross canvas resuming, change modal text to include section name to help with disambiguation instead of relying on noticing that the section title is bold (e.g. with https://media.dlib.indiana.edu/media_objects/tm70nc75d/manifest.json use something like "Resume playback from Lacquer Disc 1/1 Part 2 (40000002813915) at 00:31?"). It might be too much though.
|
New ticket to address the suggestions: #932 |



Related issue: #919
Changes in this PR:
resumeCacheprop toMediaPlayerwith a default of{ enable: false, ttlDays: 30, maxItems: 200 }to configure the feature and LRU cache capacity inlocalStorageusePlaybackPositionscustom hook implementing a bounded LRU cache inlocalStorageto persist per-canvas playback positions. This is in its own filesrc/services/save-playback-positions.jsto keep the LRU implementation with the hook implementation.timeupdateevents, skipping the first and last 5 seconds to avoid unhelpful resumesstartCanvasTimeis set in the propsresumeCache.enableis set tofalseany existing saved playback positions inlocalStorageis cleared otherwise the browser keeps this unused information indefinitely with the feature disabledImplementation notes for the resume modal:
loadedmetadataevent, which is registered viaplayer.one()method to listen for this event exactly once. This ensures the modal is shown only on the first time the player is loaded and suppressed for subsequent Canvas switches.startCanvasTimeis set, as the explicit start time takes precedenceThe resume modal looks as follows for audio and video players;
Possible future work: