SpeedyGo55
SpeedyGo55

Reputation: 9

How can I get the currently playing Song from a Browser in NodeJS?

I want to make a Plugin for Obsidian.md where I see what Track is currently Playing and, if possible, want to be able to pause/play/skip the tracks. In Wallpaper Engine the displaying works but there I just use the Inbuilt functions. How can i do this in NodeJS so it even works with YouTube Music? It is okay if it only works on Windows

I tried the MediaSession API (const mediaMetadata = navigator.mediaSession.metadata.title;) but I dont get an output besides NULL. And on google I sadly didnt find anything usable.

Sincerely Speedy

Upvotes: 0

Views: 274

Answers (1)

WaterWolf5918
WaterWolf5918

Reputation: 1

One way I can think to do this have browser extension that watches the youtube music tab and scrapes data from it to send to a local webserver written in nodejs using a websocket server and then have a obsidian plugin listen to a websocket the local webserver is sending data to.

Then for the playback controls you would do basically the same thing in reverse.

Browser extension watchs for page changes
  Page is updated 
    Extension gets music info from html elements 
      Extension sends data to local webserver 

Webserver gets date from extension
  Webserver sends data to a websocket

Plugin listens for data on websocket
  Plugin parses data and does stuff with it

Upvotes: 0

Related Questions