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

Add Media Session types #821

Closed
wants to merge 1 commit into from
Closed

Add Media Session types #821

wants to merge 1 commit into from

Conversation

Rowno
Copy link

@Rowno Rowno commented Feb 10, 2020

This adds types for the Media Session API. Fixes microsoft/TypeScript#19473

The only thing that could be improved with the types is that:

interface MediaSession {
    setActionHandler(action: MediaSessionAction, handler: MediaSessionActionHandler | null): void;
}

interface MediaSessionActionHandler {
    (details: MediaSessionActionDetails): void;
}

should really be:

interface MediaSession {
    setActionHandler(action: 'seekbackward' | 'seekforward', handler: MediaSessionSeekActionHandler | null): void;
    setActionHandler(action: 'seekto', handler: MediaSessionSeekToActionHandler | null): void;
    setActionHandler(action: MediaSessionAction, handler: MediaSessionActionHandler | null): void;
}

interface MediaSessionActionHandler {
    (details: MediaSessionActionDetails): void;
}

interface MediaSessionSeekActionHandler {
    (details: MediaSessionSeekActionDetails): void;
}

interface MediaSessionSeekToActionHandler {
    (details: MediaSessionSeekToActionDetails): void;
}

But I couldn't figure out how to insert the additional interfaces and the MediaSessionSeekActionDetails and MediaSessionSeekToActionDetails types from the widl file.

@Rowno Rowno requested a review from sandersn as a code owner February 10, 2020 08:29
@msftclas
Copy link

msftclas commented Feb 10, 2020

CLA assistant check
All CLA requirements met.

@saschanaz
Copy link
Contributor

saschanaz commented Mar 11, 2020

You might want to check addedTypes.json and its additional-signatures field.

@Rowno
Copy link
Author

Rowno commented Mar 12, 2020

I spent a couple of hours hacking around in the addedTypes.json and overridingTypes.json files but couldn't figure out how to make it work properly.

@saschanaz
Copy link
Contributor

We might need some documentation for those files... For now, something like this should work.

"callback-functions": {
  "callback-function": {
    "MediaSessionActionHandler": {
      "name": "MediaSessionActionHandler",
      "override-signatures": [
        "(details: MediaSessionSeekActionDetails): void"
      ]
    }
  }
}

And for additional-signatures:

"interfaces": {
  "interface": {
    "MediaSession": {
      "methods": {
        "method": {
          "setActionHandler": {
            "additional-signatures": [
              "setActionHandler(action: 'seekbackward' | 'seekforward', handler: MediaSessionSeekActionHandler | null): void"
            ]
          }
        }
      }
    }
  }
}

@sandersn
Copy link
Member

sandersn commented Jun 5, 2020

Additionally, caniuse.com says that only Chrome (and new Edge) support MediaSession API, so I want to wait until another browser supports this API before putting it in the standard library.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should wait until more than one engine implements it.

@orta orta added the Waiting on standards We're waiting on the standards process (or more browser support) label Jun 5, 2020
@Rowno
Copy link
Author

Rowno commented Jun 5, 2020

Fair enough

@sapphi-red
Copy link

It seems MediaSession API has landed Firefox in version 82.

@saschanaz
Copy link
Contributor

This is shipped by #1034

@github-actions close

@github-actions github-actions bot closed this Aug 25, 2021
@github-actions
Copy link
Contributor

Closing because @saschanaz is a code-owner of all the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on standards We're waiting on the standards process (or more browser support)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MediaSession not supported by TypeScript 2.3.4
6 participants