Skip to content

MediaSession not supported by TypeScript 2.3.4 #19473

@pablo-gonzalez

Description

@pablo-gonzalez

TypeScript Version: 2.3.4

Code

  navigator.mediaSession.metadata = new MediaMetadata({
    title: "Podcast Episode Title",
    artist: "Podcast Host",
    album: "Podcast Name",
    artwork: [{src: "podcast.jpg"}]
  });
  navigator.mediaSession.setActionHandler('play', function() {});
  navigator.mediaSession.setActionHandler('pause', function() {});
  navigator.mediaSession.setActionHandler('seekbackward', function() {});
  navigator.mediaSession.setActionHandler('seekforward', function() {});
  navigator.mediaSession.setActionHandler('previoustrack', function() {});
  navigator.mediaSession.setActionHandler('nexttrack', function() {});
}

Expected behavior:
MediaSession and MediaMetadata should be recognized by Typescript.

https://developer.mozilla.org/en-US/docs/Web/API/MediaSession
https://developers.google.com/web/updates/2017/02/media-session

Actual behavior:
Visual Studio Code Version 1.17.2 is showing the following Problems after saving the ts file:

message: 'Property 'mediaSession' does not exist on type 'Navigator'.'
message: 'Cannot find name 'MediaMetadata'.'

System information:

pablo@pablo-Inspiron-7520:~/projects/fpt3$ ionic info
cli packages: (/usr/lib/node_modules)

@ionic/cli-utils  : 1.13.1
ionic (Ionic CLI) : 3.13.2

global packages:

cordova (Cordova CLI) : 6.5.0

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.1.2 browser 4.1.0
Ionic Framework    : ionic-angular 3.7.1

System:

Android SDK Tools : 25.2.5
Node              : v7.10.0
npm               : 3.10.10
OS                : Linux 4.4

Misc:

backend : pro

As a workround I have installed @types/wicg-mediasession:
https://www.npmjs.com/package/@types/wicg-mediasession

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions