question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MediaSession not supported by TypeScript 2.3.4

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:13
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
jsmithcommented, Nov 8, 2020

The “solution” is not // @ts-ignore but installing @types/wicg-mediasession as stated by @pablo-gonzalez

npm install --save-dev @types/wicg-mediasession

I’m using it now and it’s working fantastic!

3reactions
MetaMmoderncommented, Jan 1, 2021

The “solution” is not // @ts-ignore but installing @types/wicg-mediasession as stated by @pablo-gonzalez

npm install --save-dev @types/wicg-mediasession

I’m using it now and it’s working fantastic!

+1, this is working, the issue may be closed imo. Also add this to some docs so it is google’d better) @jsmith thank you anf Happy New Year)

Read more comments on GitHub >

github_iconTop Results From Across the Web

MediaSession not supported by TypeScript 2.3.4 · Issue #19473
Visual Studio Code Version 1.17.2 is showing the following Problems after saving the ts file: message: 'Property 'mediaSession' does not exist ...
Read more >
@types/wicg-mediasession - npm
TypeScript definitions for Media Session API. Latest version: 1.1.4, last published: 3 months ago. Start using @types/wicg-mediasession in ...
Read more >
How to set up TypeScript
For project types which don't support Nuget, you can use the TypeScript Visual Studio extension. You can install the extension using Extensions >...
Read more >
Mastering Front-End Web Development - Tutorialspoint
Front-end web development is a science as much as an art. An accomplished front-end web developer has a profound understanding of how to...
Read more >
Visual Studio 2019 Installer Only Offers TypeScript 3.3 SDK
The product I am working on uses 2.3, and while it may be upgraded to 3.3 one day it's not going to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found