Skip to content

Conversation

@cj12312021
Copy link
Collaborator

Summary

Adds time-based activity tracking for scenes played via DLNA, enabling play count, play duration, and resume time tracking similar to the web frontend.

Changes

  • New ActivityTracker in internal/dlna/activity.go
  • Uses existing trackActivity UI setting (no new config needed)
  • Time-based tracking approach (elapsed session time / video duration)
  • 5-minute session timeout to handle aggressive client buffering

Limitations

This is a heuristic-based approach with known limitations:

  • Cannot detect actual playback position (only elapsed time)
  • Cannot detect seeking or pause state
  • Works best for linear playback

Testing

  • Unit tests added in activity_test.go
  • Manually tested with Pigasus VR Media Player

Could close #5710,

@cj12312021 cj12312021 marked this pull request as ready for review December 14, 2025 03:31
Adds time-based activity tracking for scenes played via DLNA, enabling
play count, play duration, and resume time tracking similar to the
web frontend.

Key features:
- Uses existing 'trackActivity' UI setting (no new config needed)
- Time-based tracking (elapsed session time / video duration)
- 5-minute session timeout to handle aggressive client buffering
- Minimum thresholds before saving (1% watched or 5 seconds)
- Respects minimumPlayPercent setting for play count increment

Implementation:
- New ActivityTracker in internal/dlna/activity.go
- Session management with automatic expiration
- Integration via DLNA service initialization

Limitations:
- Cannot detect actual playback position (only elapsed time)
- Cannot detect seeking or pause state
- Designed for upstream compatibility (no complex dependencies)
@cj12312021 cj12312021 force-pushed the feature/dlna-activity-tracking branch from 884e90a to aff37fb Compare December 14, 2025 04:03
@cj12312021
Copy link
Collaborator Author

Also fixes the previously closed issue #3681. The solution in the PR does, in fact, infer playback activity by tracking the HTTP request. Without implementing a more involved AVTransport Service, this is likely the most optimal solution. The biggest limitation here, as mentioned earlier, is that the resume index won’t be very accurate if the user jumps between time indexes, but most DLNA services don’t make seeking forward or backward very convenient to begin with. I believe a similar implementation is used for Plex.

@feederbox826
Copy link
Collaborator

My rationale for closing 3681 was that to do actual accurate tracking, you would have to reverse-engineer the HTTP range headers into the video block chunks and convert that into timestamps

The PR does do DLNA tracking but also makes a lot of assumptions as to watch activity and behaviour of the person - watching from the beginning to the end of a file linearly and continuously

@cj12312021
Copy link
Collaborator Author

No shade was intended by my earlier message. I discovered the closed issue yesterday after taking another pass to look for the issue requesting this feature, which I was sure existed.

Based on my research, fine-grained support, like what we have on the front end, is possible. It would introduce a lot of complexity, which likely would not be worth the time investment. The level of support provided here provides the most bang for the buck and seems to be the approach favored by similar apps. I think most who turn activity tracking on would be happy with some level of DLNA support rather than no support.

Speaking personally now, my viewing habits when using DLNA do tend to be more linear.

Fix issues with session not expiring after stopping video
@WithoutPants WithoutPants added this to the Version 0.31.0 milestone Jan 5, 2026
@WithoutPants WithoutPants added the improvement Something needed tweaking. label Jan 5, 2026
@WithoutPants WithoutPants merged commit 66cecee into stashapp:develop Jan 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Something needed tweaking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add/edit scene play duration manually

3 participants