npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gmusic-meta-ui.js

v1.120.2018

Published

Browser-side JS library for controlling Google Music through UI manipulation

Downloads

2

Readme

gmusic-meta-ui.js

Build Status GitHub release Code Climate GitHub license

Browser-side JS library for controlling Google Music through UI manipulation.

gmusic-meta-ui.js is not created by, affiliated with, or supported by Google Inc.

Getting Started

It's important to note the gmusic-meta-ui.js depends on gmusic-meta.js in order to operate correctly

npm

Install the module with: npm install gmusic-meta.js gmusic-meta-ui.js

Once installed, add it to your HTML and access it via window.GMusic.

<script>
  require('gmusic-meta.js')
  require('gmusic-meta-ui.js')
  window.gmusic = new window.GMusic(); // Our Google Music API
</script>

Vanilla

If you are not using a package manager, download the latest script at:

https://raw.githubusercontent.com/muellerweiss/gmusic-meta-ui.js/master/dist/gmusic-ui.min.js

Then, add it to your HTML and access it via window.GMusic.

<script src="gmusic.min.js"></script>
<script src="gmusic-ui.min.js"></script>
<script>
  window.gmusic = new window.GMusic(window); // Our Google Music API
</script>

Documentation

gmusic-meta-ui.js extends the GMusic constructor, window.GMusic

Data Structures

Album

{
  "id": String,           // Unique ID for this album
  "name": String,         // The name of the album
  "artist": String,       // The name of the artist for the album
  "albumArt": String,     // URL to the albumArt for this album
}

Artist

{
  "id": String,           // Unique ID for this artist
  "name": String,         // The name of the artist
  "image": String,        // URL to an image of this artist
}

Playlist

{
  "id": String,           // Unique ID for this playlist
  "name": String,         // User defined name for this playlist
  "tracks": Track[],      // An array of Track objects that make up the playlist
}

SearchResults

{
  "searchText": String,   // The text the user searched for to get these results
  "bestMatch": {
    "type": String,       // The type of result that is best.  One of "album", "artist" or "track"
    "value": Album | Artist | Track
  }
  "albums": Album[],      // An array of albums that are part of these search results
  "artists": Artist[],    // An array of artists that are part of these search results
  "tracks": Track[],      // An array of tracks taht are part of these search results
}

new GMusic(window)

Constructor for a new Google Music API.

  • window - Object - The global window object

You can read up on the namespaces and methods that gmusic-meta natively offers over in the gmusic-meta.js README

Below are the namespaces and methods that gmusic-meta-ui adds to GMusic

Playlists

playlists.getAll()

Retrieves a list of all the playlists in the users GPM library

Returns:

  • retVal Playlist[] - An array of Playlist objects

playlists.play(playlist)

Navigates to the given playlist and plays it immediately

Returns:

  • retVal Promise - A promise that resolves when the playlist starts playing. This promise can be rejected so you need to handle any errors with .catch

playlists.playWithTrack(playlist, track)

Navigates to the given playlist and plays it immediately starting at the given track

  • playlist Playlist - A Playlist object returned from getAll()
  • track Track - A Track object from the tracks property of the supplied playlist

Returns:

  • retVal Promise - A promise that resolves when the track starts playing. This promise can be rejected so you need to handle any errors with .catch

Queue

queue.clear()

Clears the current queue

queue.getTracks()

Retrieves a list of all the tracks in the users current queue

Returns:

  • retVal Track[] - An array of Track objects

queue.playTrack(track)

Attempts to play a given track in the queue. If this track is not in the queue an error will be thrown

Returns:

  • retVal Promise - A promise that resolves when the track starts playing. This promise can be rejected so you need to handle any errors with .catch

Search

search.getCurrentResults()

Retrieves a SearchResults object representing the current search results. Will throw an error if the user is not currently searching

Returns:

  • retVal SearchResults - An object of the structure of a SearchResults object

search.getSearchText()

Retrieves the current string that the user is searching for or the most recent string the user searched for. Basically whatever is in the search input field at the moment.

Returns:

  • retVal String - The value of the search input field

search.isSearching()

Determines if the user is currently searching or not

Returns:

  • retVal Boolean - True if the user is searching, False otherwise

search.performSearch(text)

Immediately triggers a new search for the given text

  • text String A word of sequence of words to search for

Returns:

  • retVal Promise - A promise that will resolve with the results of the search you just performed. The promise will be rejected with a timeout error if the search takes too long.

search.playResult(result)

Immediately attempts to play the given result. If we fail to play the given result an error will be thrown.

  • result Album | Artist | Track - An object returned from getResults() that you wish to play

Hooks

Hooks are bound the same way as the gmusic-meta.js hooks.

###.on('change:playlists') Triggers when the content of any playlist or the list of playlists changes in any way.

gmusic-meta.on('change:playlists', function (playlists) {
})
  • playlists Playlist[] - A list of Playlist objects

###.on('change:queue') Triggers when the contents of the queue is changes in any way

gmusic-meta.on('change:queue', function (queue) {
})

###.on('change:search-results') Triggers when a new search is performed and the results change

gmusic-meta.on('change:search-results', function (newResults) {
})
  • queue Track[] - A list of Track objects

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint and test via npm test.

Testing

Currently there is no testing framework. We should probably implement the gmusic-meta.js testing library in this repo aswell