Allows applications to determine whether or not the phone has a registered Apple Music account. If it does, allows queueing up songs to be played in Apple Music. Also contains some methods to manage the currently playing track.
cordova plugin add cordova-plugin-apple-music
The following methods integrate with the new Apple Music API released in iOS 9.3.
appleMusicPlugin.init(successFunction, failureFunction)
Only necessary if you want to respond to the plugin's events
appleMusicPlugin.getStatus(function(statusCode){}, failureFunction)
0 - SKCloudServiceAuthorizationStatusNotDetermined
1 - SKCloudServiceAuthorizationStatusDenied
2 - SKCloudServiceAuthorizationStatusAuthorized
3 - SKCloudServiceAuthorizationStatusRestricted
appleMusicPlugin.requestAuthorization(function(isAuthorized){}, failureFunction)
This will prompt the user asking if the application can have access to apple music. Calling this multiple times will not show the prompt more than once, if the user does not permit access the first time. Users must go into Settings -> AppName in order to grant access after the first prompt. Returns whether or not the phone will be app will be capable of queueing songs for playback.
appleMusicPlugin.getCountryCode(successFunction, failureFunction)
Returns the country code for the iTunes storefront
appleMusicPlugin.playTrack(trackId, successFunction, failureFunction)
Queues a track by id.
Example id: itunes.apple.com/fr/album/unstoppable/id984653860?i=984653861
The following methods will allow you to manipulate the currently playing track.
appleMusicPlugin.getDuration(successFunction, failureFunction)
Returns the current track's duration (in seconds)
appleMusicPlugin.getPosition(successFunction, failureFunction)
Returns the current track's position (in seconds)
appleMusicPlugin.pause(successFunction, failureFunction)
appleMusicPlugin.resume(successFunction, failureFunction)
appleMusicPlugin.seek(seconds, successFunction, failureFunction)
appleMusicPlugin.stop(successFunction, failureFunction)
The following methods will allow you to set up event handlers for the apple music player.
appleMusicPlugin.onStop(callback)
Called whenever an apple music track is stopped, interrupted, or paused.
appleMusicPlugin.onSeek(callback)
Called when the user seeks a new position within a track
appleMusicPlugin.onPlay(callback)
Called whenever an apple music track starts playing