summaryrefslogtreecommitdiff
path: root/chromium/ui/base/win/system_media_controls/system_media_controls_service.h
blob: 8b5eba68a5c06cbc1df0064c50e72b04360877bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2019 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.

#ifndef UI_BASE_WIN_SYSTEM_MEDIA_CONTROLS_SYSTEM_MEDIA_CONTROLS_SERVICE_H_
#define UI_BASE_WIN_SYSTEM_MEDIA_CONTROLS_SYSTEM_MEDIA_CONTROLS_SERVICE_H_

#include <windows.media.control.h>

#include "base/component_export.h"
#include "base/strings/string16.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace system_media_controls {

class SystemMediaControlsServiceObserver;

// The SystemMediaControlsService connects with Windows's System Media Transport
// Controls, receives media key events, and propagates those events to listening
// SystemMediaControlsServiceObservers. The SystemMediaControlsService tells the
// System Media Transport Controls which actions are currently available. The
// SystemMediaControlsService is also used to keep the System Media Transport
// Controls informed of the current media playback state and metadata.
class COMPONENT_EXPORT(SYSTEM_MEDIA_CONTROLS) SystemMediaControlsService {
 public:
  // Returns the singleton instance, creating if necessary. If the
  // SystemMediaControlsService fails to connect to the
  // SystemMediaTransportControls, this returns null.
  static SystemMediaControlsService* GetInstance();

  virtual void AddObserver(SystemMediaControlsServiceObserver* observer) = 0;
  virtual void RemoveObserver(SystemMediaControlsServiceObserver* observer) = 0;

  // Enables/disables the service.
  virtual void SetEnabled(bool enabled) = 0;

  // TODO(steimel): Add other controls.
  // Enable or disable specific controls.
  virtual void SetIsNextEnabled(bool value) = 0;
  virtual void SetIsPreviousEnabled(bool value) = 0;
  virtual void SetIsPlayEnabled(bool value) = 0;
  virtual void SetIsPauseEnabled(bool value) = 0;
  virtual void SetIsStopEnabled(bool value) = 0;

  // Setters for metadata.
  virtual void SetPlaybackStatus(
      ABI::Windows::Media::MediaPlaybackStatus status) = 0;
  virtual void SetTitle(const base::string16& title) = 0;
  virtual void SetArtist(const base::string16& artist) = 0;
  virtual void SetThumbnail(const SkBitmap& bitmap) = 0;

  // Helpers for metadata.
  virtual void ClearThumbnail() = 0;
  virtual void ClearMetadata() = 0;
  virtual void UpdateDisplay() = 0;

 protected:
  virtual ~SystemMediaControlsService();
};

}  // namespace system_media_controls

#endif  // UI_BASE_WIN_SYSTEM_MEDIA_CONTROLS_SYSTEM_MEDIA_CONTROLS_SERVICE_H_