Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MediaSessionAction[Details] enum/dict from MDN #11296

Merged
merged 3 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7964,6 +7964,12 @@
/en-US/docs/Web/API/MediaRecorder/canRecordMimeType /en-US/docs/Web/API/MediaRecorder/isTypeSupported
/en-US/docs/Web/API/MediaRecorder_API /en-US/docs/Web/API/MediaStream_Recording_API
/en-US/docs/Web/API/MediaRecorder_API/Using_the_MediaRecorder_API /en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API
/en-US/docs/Web/API/MediaSessionAction /en-US/docs/Web/API/MediaSession/setActionHandler
/en-US/docs/Web/API/MediaSessionActionDetails /en-US/docs/Web/API/MediaSession/setActionHandler
/en-US/docs/Web/API/MediaSessionActionDetails/action /en-US/docs/Web/API/MediaSession/setActionHandler
/en-US/docs/Web/API/MediaSessionActionDetails/fastSeek /en-US/docs/Web/API/MediaSession/setActionHandler
/en-US/docs/Web/API/MediaSessionActionDetails/seekOffset /en-US/docs/Web/API/MediaSession/setActionHandler
/en-US/docs/Web/API/MediaSessionActionDetails/seekTime /en-US/docs/Web/API/MediaSession/setActionHandler
/en-US/docs/Web/API/MediaSettingsRange /en-US/docs/Web/API/ImageCapture/getPhotoCapabilities
/en-US/docs/Web/API/MediaSettingsRange/max /en-US/docs/Web/API/ImageCapture/getPhotoCapabilities
/en-US/docs/Web/API/MediaSettingsRange/min /en-US/docs/Web/API/ImageCapture/getPhotoCapabilities
Expand Down
38 changes: 0 additions & 38 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -59222,44 +59222,6 @@
"Sheppy"
]
},
"Web/API/MediaSessionAction": {
"modified": "2020-10-15T22:32:38.938Z",
"contributors": [
"chrisdavidmills",
"Sheppy"
]
},
"Web/API/MediaSessionActionDetails": {
"modified": "2020-10-15T22:29:13.391Z",
"contributors": [
"chrisdavidmills",
"Sheppy"
]
},
"Web/API/MediaSessionActionDetails/action": {
"modified": "2020-10-15T22:29:15.064Z",
"contributors": [
"Sheppy"
]
},
"Web/API/MediaSessionActionDetails/fastSeek": {
"modified": "2020-10-15T22:29:15.752Z",
"contributors": [
"Sheppy"
]
},
"Web/API/MediaSessionActionDetails/seekOffset": {
"modified": "2020-10-15T22:29:15.264Z",
"contributors": [
"Sheppy"
]
},
"Web/API/MediaSessionActionDetails/seekTime": {
"modified": "2020-10-15T22:29:15.353Z",
"contributors": [
"Sheppy"
]
},
"Web/API/MediaSource": {
"modified": "2020-10-15T21:24:31.806Z",
"contributors": [
Expand Down
2 changes: 0 additions & 2 deletions files/en-us/web/api/media_session_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ navigator.mediaSession.playbackState = "playing";

- {{domxref("MediaImage")}}
- : A `MediaImage` object contains information describing an image associated with the media. This might be a CD or DVD cover, a movie poster, a poster frame, or the like.
- {{domxref("MediaSessionActionDetails")}}
- : Provides information needed in order to perform the action that has been requested, including the type of action to perform and any other information needed, such as seek distances or times.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/mediasession/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For example, a smartphone might have a standard panel in its lock screen that pr
## Methods

- {{domxref("MediaSession.setActionHandler", "setActionHandler()")}}
- : Sets an action handler for a [media session action](/en-US/docs/Web/API/MediaSessionAction), such as play or pause.
- : Sets an action handler for a media session action, such as play or pause.
- {{domxref("MediaSession.setPositionState", "setPositionState()")}}
- : Sets the current playback position and speed of the media currently being presented.

Expand Down
75 changes: 47 additions & 28 deletions files/en-us/web/api/mediasession/setactionhandler/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ browser-compat: api.MediaSession.setActionHandler
---
{{APIRef("Media Session API")}}

The **`setActionHandler()`** method of the
{{domxref("MediaSession")}} interface sets a handler for a media session action. These
actions let a web app receive notifications when the user engages a device's built-in
physical or onscreen media controls, such as play, stop, or seek buttons.
The **`setActionHandler()`** method of the {{domxref("MediaSession")}} interface sets a handler for a media session action.
These actions let a web app receive notifications when the user engages a device's built-in physical or onscreen media controls, such as play, stop, or seek buttons.

## Syntax

Expand All @@ -31,33 +29,59 @@ navigator.mediaSession.setActionHandler(type, callback)

- `type`
- : A {{domxref("DOMString")}} representing an action type to listen for. It will be one
of `{{anch("play")}}`,
`{{anch("pause")}}`, `{{anch("stop")}}`,
`{{anch("seekbackward")}}`, `{{anch("seekforward")}}`, `{{anch("seekto")}}`, `{{anch("skipad")}}`,`{{anch("previoustrack")}}`,
or `{{anch("nexttrack")}}`. Further details on the action types can be
found below under {{anch("Media session actions")}}.
of the following:
- `nexttrack`
- : Advances playback to the next track.
- `pause`
- : Pauses playback of the media.
- `play`
- : Begins (or resumes) playback of the media.
- `previoustrack`
- : Moves back to the previous track.
- `seekbackward`
- : Seeks backward through the media from the current position.
The `seekOffset` property passed to the callback specifies the amount of time to seek backward.
- `seekforward`
- : Seeks forward from the current position through the media.
The `seekOffset` property passed to the callback specifies the amount of time to seek forward.
- `seekto`
- : Moves the playback position to the specified time within the media.
The time to which to seek is specified in the `seekTime` property passed to the callback.
If you intend to perform multiple `seekto` operations in rapid succession, you can also specify the `fastSeek` property passed to the callback with a value of `true`.
This lets the browser know it can take steps to optimize repeated operations, and is likely to result in improved performance.
- `skipad`
- : Skips past the currently playing advertisement or commercial.
This action may or may not be available, depending on the platform and {{Glossary("user agent")}}, or may be disabled due to subscription level or other circumstances.
- `stop`
- : Halts playback entirely.
- `callback`
- : A function to call when the specified action type is invoked. The callback receives
no input parameters, and should not return a value.
- : A function to call when the specified action type is invoked. The callback should not return a value. The callback receives a dictionary containing the following properties:
- `action`
- : A {{domxref("DOMString")}} representing the action type. This property allows a single callback to handle multiple action types.
- `fastSeek` {{optional_inline}}
- : An `{{anch("seekto")}}` action may *optionally* include this property, which is a Boolean value indicating whether or not to perform a "fast" seek.
A "fast" seek is a seek being performed in a rapid sequence, such as when fast-forwarding or reversing through the media, rapidly skipping through it.
This property can be used to indicate that you should use the shortest possible method to seek the media.
`fastSeek` is not included on the final action in the seek sequence in this situation.
- `seekOffset` {{optional_inline}}
- : If the `action` is either `{{anch("seekforward")}}` or `{{anch("seekbackward")}}` and this property is present, it is a floating point value which indicates the number of seconds to move the play position forward or backward.
If this property isn't present, those actions should choose a reasonable default distance to skip forward or backward (such as 7 or 10 seconds).
- `seekTime` {{optional_inline}}
- : If the `action` is `{{anch("seekto")}}`, this property must be present and must be a floating-point value indicating the absolute time within the media to move the playback position to, where 0 indicates the beginning of the media. This property is not present for other action types.

### Return value

`undefined`.

## Description

To remove a previously-established action handler, call `setActionHandler()`
again, specifying `null` as the `callback`.
To remove a previously-established action handler, call `setActionHandler()` again, specifying `null` as the `callback`.

The action handler receives as input a single parameter: an object conforming to
the {{domxref("MediaSessionActionDetails")}} dictionary, which provides both the action
type (so the same function can handle multiple action types), as well as data needed in
order to perform the action.
The action handler receives as input a single parameter: an object which provides both the action type (so the same function can handle multiple action types), as well as data needed in order to perform the action.

## Examples

This example creates a new media session and assigns action handlers (which don't do
anything) to it.
This example creates a new media session and assigns action handlers (which don't do anything) to it.

```js
if ('mediaSession' in navigator) {
Expand Down Expand Up @@ -87,8 +111,7 @@ if ('mediaSession' in navigator) {
}
```

The following example sets up two functions for playing and pausing, then uses them as
callbacks with the relevant action handlers.
The following example sets up two functions for playing and pausing, then uses them as callbacks with the relevant action handlers.

```js
const actionHandlers = [
Expand Down Expand Up @@ -126,8 +149,7 @@ for (const [action, handler] of actionHandlers) {
}
```

This example uses appropriate action handlers to allow seeking in either direction
through the playing media.
This example uses appropriate action handlers to allow seeking in either direction through the playing media.

```js
let skipTime = 10; // Time to skip in seconds
Expand All @@ -152,9 +174,7 @@ navigator.mediaSession.setActionHandler('nexttrack', null);

### Supporting multiple actions in one handler function

You can also, if you prefer, use a single function to handle multiple action types, by
checking the value of the `MediaSessionActionDetails` object's
{{domxref("MediaSessionActionDetails.action", "action")}} property:
You can also, if you prefer, use a single function to handle multiple action types, by checking the value of the `action` property:

```js
let skipTime = 7;
Expand All @@ -175,8 +195,7 @@ function handleSeek(details) {
}
```

Here, the `handleSeek()` function handles
both `seekbackward` and `seekforward` actions.
Here, the `handleSeek()` function handles both `seekbackward` and `seekforward` actions.

## Specifications

Expand Down
127 changes: 0 additions & 127 deletions files/en-us/web/api/mediasessionaction/index.md

This file was deleted.

51 changes: 0 additions & 51 deletions files/en-us/web/api/mediasessionactiondetails/action/index.md

This file was deleted.

Loading