• Thomas Guilbert's avatar
    Sync WMPI's play/pause during RemotePlayback · 9f575d28
    Thomas Guilbert authored
    Currently, if a device starts a RemotePlayback session and an external
    device plays/pauses the video (via the Android cast notification), the
    WMPI that started the casting session never gets updated. This means
    that the user will see the video element on their phone as "playing",
    with no media time update, or they will see the local video as paused
    when the cast video is clearly playing.
    
    This CL addresses the issue by requesting Blink to play/pause the
    HTMLMediaElement to match the state of the remotely playing video.
    This is done by bubbling up play state changes from the
    FlingingRenderer to WMPI via the OnRemotePlayStateChange interface.
    
    To detect an external play state change, we save whether the last
    command from WMPI was a play or a pause, and propagate a change whenever
    we get a MediaStatus update that is of the opposite play state. The
    cast device does not care if it receives a "PLAY" command while already
    playing (or "PAUSE" when paused). Therefore, after calling
    OnRemotePlayStateChange, FlingingRenderer does not need to treat the
    commands it receives any differently than a user initiated command.
    
    NOTE: This approach works reasonably well, but is not an ironclad
    guarantee of consistency. We are fine with missing a few changes,
    because all the user has to do is tap the video element once to return
    to a consistent state. Being too aggressive in trying to detect play
    state changes sometimes causes the phone to go in a feedback loop,
    where it constantly issues commands while the UI wildly switches
    between playing and pausing.
    
    Bug: 790766
    Change-Id: If230c412a6a020c88970e1c9475d8fdc97976c3b
    Reviewed-on: https://chromium-review.googlesource.com/c/1413398
    Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
    Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#626188}
    9f575d28
mojo_renderer.cc 12.7 KB