blob: 2aa9af7b73828e8c16036c1a189cc47e1388b76b [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module media_session.mojom;
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "services/media_session/public/mojom/media_session.mojom";
interface MediaControllerManager {
// Creates a MediaController linked to a specific session with |request_id|.
// This should match the |request_id| from the AudioFocusRequestState.
CreateMediaControllerForSession(
MediaController& request,
mojo_base.mojom.UnguessableToken request_id);
// Creates a MediaController linked to the active session. This will
// automatically route commands to the correct session if the active session
// changes. If there is no active session then commands will be no-ops.
CreateActiveMediaController(MediaController& request);
};
// Controls a MediaSession. If the media session is not controllable then the
// commands will be no-ops.
interface MediaController {
// Suspend the media session.
Suspend();
// Resume the media session.
Resume();
// Stop the media session.
Stop();
// This will either suspend or resume the media session based on the
// playback state.
ToggleSuspendResume();
// Adds an observer that will forward events from the active media session.
// If the active session changes then observers do not need to be readded.
// Adding the observer will update the observer with the latest state.
AddObserver(MediaControllerObserver observer);
// Skip to the previous track. If there is no previous track then this will be
// a no-op.
PreviousTrack();
// Skip to the next track. If there is no next track then this will be a
// no-op.
NextTrack();
// Seek the media session. If the media cannot seek then this will be a
// no-op. The |seek_time| is the time delta that the media will seek by and
// supports both positive and negative values. This value cannot be zero.
// The |kDefaultSeekTimeSeconds| provides a default value for seeking by a
// few seconds.
Seek(mojo_base.mojom.TimeDelta seek_time);
};
// The observer for observing media controller events. This is different to a
// MediaSessionObserver because a media controller can have nullable session
// info which will be null if it is not bound to a media session. This would
// be invalid for a media session because it must always have some state.
interface MediaControllerObserver {
// Called when the state of the bound media session changes. If |info| is
// empty then the controller is no longer bound to a media session.
MediaSessionInfoChanged(MediaSessionInfo? info);
// Called when the bound media session has changed metadata. If |metadata|
// is null then it can be reset, e.g. the media that ws being played has
// been stopped.
MediaSessionMetadataChanged(MediaMetadata? metadata);
// Called when the bound media session action list has changed. This tells
// the observer which actions can be used to control the session.
MediaSessionActionsChanged(array<MediaSessionAction> action);
};