INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Up Next?  (Read 1292 times)

retiredteacherguy

  • World Citizen
  • ***
  • Posts: 108
Up Next?
« on: February 05, 2023, 07:13:29 am »

Is there a way to pull in the name of the next track into Track Info?

I checked here https://jriver.com/DevZone/MJFields.h

but I'm not spotting anything
Logged

retiredteacherguy

  • World Citizen
  • ***
  • Posts: 108
Re: Up Next?
« Reply #1 on: February 08, 2023, 10:10:37 pm »

OK, well there is likely a less-complicated way to do it, but here is how I got it done:

Code: [Select]
fetch("http://<yourIP>:52199/MCWS/v1/Playback/Info?Zone=-1")
  .then((response) => response.text())
  .then((text) => {
    const parser = new DOMParser();
    const xml = parser.parseFromString(text, "text/xml");
    nextFileKey = xml.querySelector('Item[Name="NextFileKey"]').textContent;
    return nextFileKey;
  })
  .then((nextFileKey) => {
    return fetch(
      `http://<yourIP>4:52199/MCWS/v1/File/GetInfo?Action=JSON&File=${nextFileKey}`
    );
  })
  .then((response) => response.json())
  .then((data) => {
    const nextSongInfo = data[0];
    nextSongName = nextSongInfo.Name;
    nextSongArtist = nextSongInfo.Artist;
    const nextSongThumbnail =
      "http://<yourIP>:52199/MCWS/v1/File/GetImage?File=" +
      nextFileKey +
      "&FileType=Key&Type=Thumbnail&Format=jpg";
    console.log(nextSongName, nextSongThumbnail);
    const img = new Image();
    img.src = nextSongThumbnail;
    img.width = 150;
    img.height = 150;
    document.getElementById("nextSongThumbnail").appendChild(img);
    document.getElementById("nextSongName").innerHTML = nextSongName;
    document.getElementById("nextSongArtist").innerHTML = nextSongArtist;
  });

I like having Display View showing the current track plus the next song...that's just my vibe.

Logged

theoctavist

  • World Citizen
  • ***
  • Posts: 228
  • a bad liver and a broken heart.
Re: Up Next?
« Reply #2 on: April 20, 2023, 08:47:54 pm »

OK, well there is likely a less-complicated way to do it, but here is how I got it done:

Code: [Select]
fetch("http://<yourIP>:52199/MCWS/v1/Playback/Info?Zone=-1")
  .then((response) => response.text())
  .then((text) => {
    const parser = new DOMParser();
    const xml = parser.parseFromString(text, "text/xml");
    nextFileKey = xml.querySelector('Item[Name="NextFileKey"]').textContent;
    return nextFileKey;
  })
  .then((nextFileKey) => {
    return fetch(
      `http://<yourIP>4:52199/MCWS/v1/File/GetInfo?Action=JSON&File=${nextFileKey}`
    );
  })
  .then((response) => response.json())
  .then((data) => {
    const nextSongInfo = data[0];
    nextSongName = nextSongInfo.Name;
    nextSongArtist = nextSongInfo.Artist;
    const nextSongThumbnail =
      "http://<yourIP>:52199/MCWS/v1/File/GetImage?File=" +
      nextFileKey +
      "&FileType=Key&Type=Thumbnail&Format=jpg";
    console.log(nextSongName, nextSongThumbnail);
    const img = new Image();
    img.src = nextSongThumbnail;
    img.width = 150;
    img.height = 150;
    document.getElementById("nextSongThumbnail").appendChild(img);
    document.getElementById("nextSongName").innerHTML = nextSongName;
    document.getElementById("nextSongArtist").innerHTML = nextSongArtist;
  });

I like having Display View showing the current track plus the next song...that's just my vibe.

pardon my lack of experience sir, but where do i put that code to get that result? can you break it down for me like im dumb. thank you sir.
Logged
Pages: [1]   Go Up