Repository: electron
Issue: [Feature Request]: MediaSession API bindings
Labels: enhancement :sparkles:

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Problem Description

The [MediaSession API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API) provides a way for web applications to communicate to the browser client which media-related actions it supports. In response, a browser client can display relevant controls pertaining to an active media session. This is used for media playback or video conferencing applications. More examples and info on the API can be found at https://web.dev/media-session/

While web applications are able to register MediaSession action handlers, it's not possible to know which are registered from the browser/main process. Applications could use this information to show controls integrated more closely with the OS.

### Proposed Solution

The [MediaSession interface](https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/media_session.h) exists in Chromium for each WebContents. It can be used to control an active media session and receive updates on when actions are registered. Providing V8 bindings for this interface would allow Electron applications to be aware of such media actions and to build their own interfaces on top of them.

```ts
interface WebContents {
  /** Lazy property getter for the corresponding MediaSession. */
  get mediaSession(): MediaSession;
}

/**
 * Class for binding content::MediaSession.
 * 
 * https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/media_session.h
 * https://source.chromium.org/chromium/chromium/src/+/main:services/media_session/public/mojom/media_session.mojom
 */
interface MediaSession {
  // MediaSession mojo interface bindings
  suspend(): void;
  resume(): void;
  startDucking(): void;
  stopDucking(): void;
  getMediaSessionInfo(): Promise<MediaSessionInfo>;
  previousTrack(): void;
  nextTrack(): void;
  skipAd(): void;
  seek(seekTime: number): void;
  stop(): void;
  getMediaImageBitmap(): Promise<NativeImage>;
  seekTo(seekTime: number): void;
  scrubTo(seekTime: number): void;
  toggleMicrophone(): void;
  toggleCamera(): void;
  hangUp(): void;
  raise(): void;
  setMute(muted: boolean): void;

  // MediaSessionObserver bindings
  on('info-changed', listener: (info: MediaSessionInfo) => void): void;
  on('metadata-changed', listener: (metadata: MediaMetadata) => void): void;
  on('actions-changed', listener: (actions: MediaSessionAction[]) => void): void;
  on('images-changed', listener: (images: Map<MediaSessionImageType, NativeImage>) => void): void;
  on('position-changed', listener: (position: MediaPosition) => void): void;
}

```

### Alternatives Considered

None

### Additional Information

As new [media action handlers](https://w3c.github.io/mediasession/#actions-model) are defined in the MediaSession standard, additional methods will need to be added to the Electron API to properly support them.