DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (c68fe15a81fc)

VCS Links

Line Code
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef DOM_MEDIA_MEDIACONTROL_CONTENTPLAYBACKCONTROLLER_H_
#define DOM_MEDIA_MEDIACONTROL_CONTENTPLAYBACKCONTROLLER_H_


#include "MediaControlKeySource.h"
#include "nsPIDOMWindow.h"
#include "mozilla/dom/BrowsingContext.h"

namespace mozilla {
namespace mozilla {
namespace dom {

class MediaSession;

/**
/**
 * This interface is used to handle different playback control actions in the
 * content process. Most of the methods are designed based on the
 * MediaSessionAction values, which are defined in the media session spec [1].
 *
 * The reason we need that is to explicitly separate the implementation from all
 * different defined methods. If we want to add a new method in the future, we
 * can do that without modifying other methods.
 *
 * If the active media session has a corresponding MediaSessionActionHandler,
 * then we would invoke it, or we would do nothing. However, for certain
 * actions, such as `play`, `pause` and `stop`, we have default action handling
 * actions, such as `play`, `pause` and `stop`, we have default action handling
 * in order to control playback correctly even if the website doesn't use media
 * session at all or the media session doesn't have correspending action handler
 * [2].
 *
 * [1] https://w3c.github.io/mediasession/#enumdef-mediasessionaction
 * [1] https://w3c.github.io/mediasession/#enumdef-mediasessionaction
 * [2]
 * https://w3c.github.io/mediasession/#ref-for-active-media-session%E2%91%A1%E2%93%AA
 */
class MOZ_STACK_CLASS ContentPlaybackController {
 public:
 public:
  explicit ContentPlaybackController(BrowsingContext* aContext);
  ~ContentPlaybackController() = default;

  void Focus();
  void Play();
  void Pause();
  void Pause();
  void SeekBackward();
  void SeekForward();
  void PreviousTrack();
  void NextTrack();
  void SkipAd();
  void SkipAd();
  void Stop();
  void SeekTo();

 private:
  void NotifyContentMediaControlKeyReceiver(MediaControlKey aKey);
  void NotifyContentControlKeyEventReceiver(MediaControlKeysEvent aEvent);
  void NotifyMediaSession(MediaSessionAction aAction);
  void NotifyMediaSessionWhenActionIsSupported(MediaSessionAction aAction);
  bool IsMediaSessionActionSupported(MediaSessionAction aAction) const;
  MediaSession* GetMediaSession() const;


  RefPtr<BrowsingContext> mBC;
};

class ContentMediaControlKeyHandler {
 public:
 public:
  static void HandleMediaControlKey(BrowsingContext* aContext,
                                    MediaControlKey aKey);
};
};

}  // namespace dom
}  // namespace mozilla

#endif
#endif