How to Implement Cross-Device Playback Progress Sync: Data Model, Conflict Resolution, and Reliability

    This article explains how to build cross-device playback progress synchronization, where users can pause on one device and resume on another under the same account. It covers a progress data model keyed by user and content, throttled and idempotent client reporting, deterministic conflict resolution rules for concurrent writes, cache-first fetch and resume behavior, and operational concerns such as offline replay, monitoring, and capacity. It also outlines privacy and compliance practices, including minimal data collection and a sync opt-out, without relying on any vendor-specific APIs.

    1. Why Cross-Device Playback Sync Is Not Simple

    In content applications, users frequently switch between phones, tablets, web browsers, and desktop clients. The product goal is straightforward: let users stop watching halfway and continue on another device. Engineering, however, has to deal with network jitter, concurrent writes from multiple devices, inconsistent clocks, growing data volume, and privacy compliance. The intent behind “sign in to sync playback progress, post danmaku, and leave comments across devices” is fundamentally a cross-device state synchronization problem: using the account as the primary key, reliably aggregate progress scattered across devices, merge it, and replay it on any device.

    A simple flow of “client reports, server stores, client fetches” may be enough for a single user on a single device. Once multiple devices and weak networks enter the picture, however, it leads to progress regression, duplicate records, and lost updates. The problem therefore needs to be abstracted into a complete data and protocol design rather than a pile of disconnected endpoints.

    2. Core Data Model: An Account-Keyed Progress Entity

    Use “user ID + content ID” as the unique key for a progress table. The fields should include at least: position in seconds, total content duration, update timestamp, client source identifier, content status (not started / watching / completed), and a version number. The version number supports concurrency control, and the source identifier determines priority when resolving conflicts.

    1. CREATE TABLE playback_progress (
    2. user_id BIGINT NOT NULL,
    3. content_id BIGINT NOT NULL,
    4. position_ms INT NOT NULL,
    5. duration_ms INT NOT NULL,
    6. status TINYINT NOT NULL,
    7. source_device VARCHAR(32) NOT NULL,
    8. updated_at BIGINT NOT NULL,
    9. version BIGINT NOT NULL,
    10. PRIMARY KEY (user_id, content_id)
    11. );

    The key design choice here is to express progress as an “absolute position + total duration” pair rather than a “percentage watched,” which avoids conversion errors caused by differences in resolution or transcoding across devices. A monotonic version number also replaces the naive “last write wins” strategy, providing a basis for conflict merging.

    3. Reporting Strategy: Throttling, Batching, and Idempotency

    The client should not write to the database on every heartbeat. A common approach is to trigger reporting at fixed intervals during playback (for example, every 15 to 30 seconds) or on key events (pause, episode switch, exit, backgrounding), with local throttling and merging to reduce the number of requests. Each report should carry an idempotency key, such as “user + content + a monotonically increasing client event sequence number,” so the server can deduplicate and avoid duplicate writes caused by weak-network retries.

    1. {
    2. "content_id": 10086,
    3. "position_ms": 754000,
    4. "duration_ms": 1500000,
    5. "status": 1,
    6. "source_device": "tablet",
    7. "event_seq": 20250401,
    8. "client_time": 1712000000000
    9. }

    Before writing, the server validates the idempotency key and version number. If the version is stale, it rejects the write and asks the client to fetch again. This turns “concurrent writes” into a decidable conflict event instead of a silent overwrite.

    4. Conflict Merging: Rules for Concurrent Multi-Device Updates

    When multiple devices watch the same content at the same time, the arbitration rules must be explicit. Three common approaches are used in the industry. The first is “maximum progress wins,” which takes the position further along and suits continuous viewing. The second is “most recently active wins,” weighted by update time and source trustworthiness. The third is “scenario-based strategy,” for example treating the “completed” status as irreversible once reached, so it cannot be overwritten by a lower progress value. A real implementation can combine all three: state machine first, then progress, then version and timestamp.

    1. if new.status == FINISHED and old.status != FINISHED: accept new
    2. elif new.position_ms > old.position_ms: accept new
    3. elif new.position_ms == old.position_ms and new.version > old.version: accept new
    4. else: reject and return current

    The benefit of these rules is that the logic is explainable and testable, and it gives clients holding stale cached values a clear “server is authoritative” convergence path.

    5. Fetching and Resume: Making Continuation Seamless

    When the client enters the playback page, it first reads the local cache and renders immediately, then asynchronously fetches server progress. If the server version is higher, it jumps smoothly and shows a message like “Jumped to your last position.” To avoid the jarring feeling of jumping back to the beginning, a minimum threshold can be set (for example, if less than 5 seconds remain, do not prompt and just play from the start). The fetch endpoint should support batch retrieval, returning progress for multiple pieces of content in one call to reduce first-screen requests.

    6. Reliability and Operations: Resume After Disconnect, Monitoring, and Capacity

    Under weak networks, persist a pending-report queue locally and replay it in order once the network recovers. On the server side, use a message queue to smooth out traffic spikes and perform idempotency checks before writing to the database. For operations, set up monitoring and alerts for “report success rate, merge conflict rate, and average sync latency,” and apply hot/cold tiering to the progress table by user dimension. Historical data can be archived to object storage to reduce pressure on the online database. If general cloud capabilities are used, they can be combined as follows: a container platform to host stateless services, a message queue to buffer writes, and logging and monitoring/alerting services for observability.

    7. Privacy and Compliance: Minimization and Opt-Out

    Playback records are user behavior data and should follow the principle of minimal collection, retaining only fields required by the business. Provide a “clear watch history” option and a “disable sync” switch. Encrypt data in transit and at rest, and restrict access through account authentication. This satisfies both the product experience and compliance requirements.

    8. Summary

    Cross-device playback progress sync is essentially an “account-level state consistency” problem. With a data model keyed by user and content, throttled reporting with idempotency keys, explainable conflict resolution rules, cache-first fetch and resume, and operational safeguards such as queue-based traffic smoothing and monitoring alerts, you can build stable, scalable cross-device continuation without depending on any vendor-specific proprietary APIs. The general cloud component categories offered by Baidu AI Cloud can serve as a reference architecture foundation for hosting such stateless services and data pipelines.