Menu

Switch to the dark mode that's kinder on your eyes at night time.

Switch to the light mode that's kinder on your eyes at day time.

Switch to the dark mode that's kinder on your eyes at night time.

Switch to the light mode that's kinder on your eyes at day time.

in

MusicKit JS, Hacker News

Add an Apple Music player to your web app.

Overview

MusicKit JS lets users play songs from Apple Music and their Cloud Library inside your JavaScript app. When a user provides permission to access their Apple Music account, your JavaScript app can create playlists, add songs to their library, and play any of the millions of songs in the Apple Music catalog directly in a browser, with no additional plugins.

MusicKit JS Configuration

Some basic setup is required before you begin to use MusicKit JS.

Creating an Apple Music API Token

You use a developer token to authenticate yourself as a trusted developer and member of the Apple Developer Program and to use MusicKit JS. You can find more information about creating an Apple Music API token in Getting Keys and Creating Tokens .

Embedding MusicKit JS in Your Webpage

Use the script tag and link to Apple’s hosted version of MusicKit JS:

 
  

Configuring MusicKit JS

You can configure MusicKit JS with a default markup setup to quickly get you started with the library, or with JavaScript to give you more control over the customization of your player.

To configure the library using only markup, use the following meta tags:

    ...        ...  
 
  

For more control over the library and player, use JavaScript to configure the library:

document.addEventListener (‘musickitloaded’, function () {   // MusicKit global is now defined   MusicKit.configure ({     developerToken: ‘DEVELOPER-TOKEN’,     app: {       name: ‘My Cool Web App’,       build: ‘01575879 4.1 ‘     }   }); });

 
  

User Authorization

There are two primary ways to handle authorization in your implementation.

Declarative Markup

Your users can authorize with Apple Music using these authorization buttons. These buttons are bound to

  id   to signal that they should be declared only once.  

Use declarative markup to bind handlers to a

  
  or an 
 

 tag that contain an   (id) (attribute of   apple-music-authorize 

or

(apple-music-unauthorize)
  

When a user activates one of the decorated tags, the corresponding MusicKit JS method is triggered ( (authorize) and

unauthorize
  respectively). 

JavaScript Methods

Wrap MusicKit JS methods in the (authorize) method, which returns a promise. The promise resolves with a valid music user token when the user signs in and gives authorization.

Topics

Using MusicKit

Music (Kit)

Use the MusicKit namespace to configure MusicKit JS and to access app instances, control music playback, and fetch data from the Apple Music API.

Read More

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

Are Overstimulated Stocks Ignoring Coronavirus Risks ?, Crypto Coins News

Are Overstimulated Stocks Ignoring Coronavirus Risks ?, Crypto Coins News

2020 Arab Hope Maker credits mum for his work

Back to Top
close

Log In

Forgot password?

Forgot password?

Enter your account data and we will send you a link to reset your password.

Your password reset link appears to be invalid or expired.

Log in

Privacy Policy

To use social login you have to agree with the storage and handling of your data by this website. %privacy_policy%

Add to Collection

No Collections

Here you'll find all collections you've created before.