Requires iOS 16 or higher
npm install capacitor-plugin-musickit
npx cap sync
addListener('playbackStateDidChange', ...)
addListener('nowPlayingItemDidChange', ...)
addListener('authorizationStatusDidChange', ...)
addRating(...)
api(...)
authorize()
configure(...)
deleteRating(...)
echo(...)
getCatalogAlbums(...)
getCatalogArtists(...)
getCurrentIndex()
getCurrentPlaybackDuration()
getCurrentPlaybackTime()
getCurrentSong()
getLibraryAlbums(...)
getLibraryArtists(...)
getLibraryPlaylists(...)
getLibrarySongs(...)
getQueueSongs()
getRatings(...)
getRepeatMode()
getShuffleMode()
hasMusicSubscription()
isAuthorized()
nextPlay()
pause()
play(...)
previousPlay()
seekToTime(...)
setQueue(...)
setRepeatMode(...)
setShuffleMode(...)
setSong(...)
stop()
unauthorize()
- Interfaces
- Type Aliases
addListener(eventName: "playbackStateDidChange", listenerFunc: PlaybackStateDidChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'playbackStateDidChange' |
listenerFunc |
PlaybackStateDidChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: "nowPlayingItemDidChange", listenerFunc: NowPlayingItemDidChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'nowPlayingItemDidChange' |
listenerFunc |
NowPlayingItemDidChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: "authorizationStatusDidChange", listenerFunc: AuthorizationStatusDidChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'authorizationStatusDidChange' |
listenerFunc |
AuthorizationStatusDidChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addRating(options: AddRatingOptions) => Promise<void>
Param | Type |
---|---|
options |
AddRatingOptions |
api<T>(options: ApiOptions) => Promise<ApiResult<T>>
Param | Type |
---|---|
options |
ApiOptions |
Returns: Promise<ApiResult<T>>
authorize() => Promise<void>
configure(options: ConfigureOptions) => Promise<void>
Param | Type |
---|---|
options |
ConfigureOptions |
deleteRating(options: DeleteRatingOptions) => Promise<void>
Param | Type |
---|---|
options |
DeleteRatingOptions |
echo(options: EchoOptions) => Promise<EchoResult>
Param | Type |
---|---|
options |
EchoOptions |
Returns: Promise<EchoResult>
getCatalogAlbums(options: GetCatalogAlbumsOptions) => Promise<GetCatalogAlbumsResult>
Param | Type |
---|---|
options |
GetCatalogAlbumsOptions |
Returns: Promise<GetCatalogAlbumsResult>
getCatalogArtists(options: GetCatalogArtistsOptions) => Promise<GetCatalogArtistsResult>
Param | Type |
---|---|
options |
GetCatalogArtistsOptions |
Returns: Promise<GetCatalogArtistsResult>
getCurrentIndex() => Promise<GetCurrentIndexResult>
Returns: Promise<GetCurrentIndexResult>
getCurrentPlaybackDuration() => Promise<GetCurrentPlaybackTimeResult>
Returns: Promise<GetCurrentPlaybackTimeResult>
getCurrentPlaybackTime() => Promise<GetCurrentPlaybackTimeResult>
Returns: Promise<GetCurrentPlaybackTimeResult>
getCurrentSong() => Promise<GetCurrentSongResult>
Returns: Promise<GetCurrentSongResult>
getLibraryAlbums(options: GetLibraryAlbumsOptions) => Promise<GetLibraryAlbumsResult>
Param | Type |
---|---|
options |
GetLibraryAlbumsOptions |
Returns: Promise<GetLibraryAlbumsResult>
getLibraryArtists(options: GetLibraryArtistsOptions) => Promise<GetLibraryArtistsResult>
Param | Type |
---|---|
options |
GetLibraryArtistsOptions |
Returns: Promise<GetLibraryArtistsResult>
getLibraryPlaylists(options: GetLibraryPlaylistsOptions) => Promise<GetLibraryPlaylistsResult>
Param | Type |
---|---|
options |
GetLibraryPlaylistsOptions |
Returns: Promise<GetLibraryPlaylistsResult>
getLibrarySongs(options: GetLibrarySongsOptions) => Promise<GetLibrarySongsResult>
Param | Type |
---|---|
options |
GetLibrarySongsOptions |
Returns: Promise<GetLibrarySongsResult>
getQueueSongs() => Promise<GetQueueSongsResult>
Returns: Promise<GetQueueSongsResult>
getRatings(options: GetRatingsOptions) => Promise<RatingsResult>
Param | Type |
---|---|
options |
GetRatingsOptions |
Returns: Promise<RatingsResult>
getRepeatMode() => Promise<GetRepeatModeResult>
Returns: Promise<GetRepeatModeResult>
getShuffleMode() => Promise<GetShuffleModeResult>
Returns: Promise<GetShuffleModeResult>
hasMusicSubscription() => Promise<ActionResult>
Returns: Promise<ActionResult>
isAuthorized() => Promise<ActionResult>
Returns: Promise<ActionResult>
nextPlay() => Promise<void>
pause() => Promise<void>
play(options: PlayOptions) => Promise<void>
Param | Type |
---|---|
options |
PlayOptions |
previousPlay() => Promise<void>
seekToTime(options: SeekToTimeOptions) => Promise<void>
Param | Type |
---|---|
options |
SeekToTimeOptions |
setQueue(options: SetQueueOptions) => Promise<void>
Param | Type |
---|---|
options |
SetQueueOptions |
setRepeatMode(options: SetRepeatModeOptions) => Promise<void>
Param | Type |
---|---|
options |
SetRepeatModeOptions |
setShuffleMode(options: SetShuffleModeOptions) => Promise<void>
Param | Type |
---|---|
options |
SetShuffleModeOptions |
setSong(options: SetSongOptions) => Promise<SetSongResult>
Param | Type |
---|---|
options |
SetSongOptions |
Returns: Promise<SetSongResult>
stop() => Promise<void>
unauthorize() => Promise<void>
Prop | Type |
---|---|
remove |
() => Promise<void> |
Prop | Type |
---|---|
config |
MusicKit.Configuration |
Prop | Type |
---|---|
value |
string |
Prop | Type |
---|---|
value |
string |
Prop | Type |
---|---|
ids |
string[] |
limit |
number |
offset |
number |
Prop | Type |
---|---|
index |
number |
Prop | Type |
---|---|
time |
number |
Prop | Type |
---|---|
item |
MusicKit.MediaItem |
Prop | Type |
---|---|
items |
MediaItem[] |
Prop | Type |
---|---|
mode |
RepeatMode |
Prop | Type |
---|---|
mode |
ShuffleMode |
Prop | Type |
---|---|
result |
boolean |
Prop | Type |
---|---|
index |
number |
Prop | Type |
---|---|
time |
number |
Prop | Type |
---|---|
ids |
string[] |
Prop | Type |
---|---|
mode |
RepeatMode |
Prop | Type |
---|---|
mode |
ShuffleMode |
Prop | Type |
---|---|
albumTitle |
string |
librarySongId |
string |
result |
boolean |
Prop | Type |
---|---|
albumTitle |
string |
forcePreview |
boolean |
librarySongId |
string |
previewUrl |
string |
songId |
string |
songTitle |
string |
(data: PlaybackStateDidChangeResult): void
{ state: PlaybackState; }
keyof typeof MusicKit.PlaybackStates
(data: NowPlayingItemDidChangeResult): void
{ index: number; item: MusicKit.MediaItem; }
(data: AuthorizationStatusDidChangeResult): void
{ status: AuthorizationStatus; }
"unavailable" | "notDetermined" | "denied" | "restricted" | "authorized"
{ id: string; type: MusicKit.AppleMusicAPI.RatingType; value: MusicKit.Rating; }
MusicKit.Relationship<T> | MusicKit.SearchRelationship
{ options?: MusicKit.AppleMusicAPI.Options; params?: MusicKit.AppleMusicAPI.Params; url: string; }
{ id: string; type: MusicKit.AppleMusicAPI.RatingType; }
MusicKit.Relationship<MusicKit.Albums>
{ artistId?: string; libraryId?: string; musicVideoId?: string; songId?: string; } & GetMultiDataOptions
MusicKit.Relationship<MusicKit.Artists>
{ albumId?: string; libraryId?: string; musicVideoId?: string; songId?: string; songIdForComposers?: string; } & GetMultiDataOptions
MusicKit.Relationship<MusicKit.LibraryAlbums>
{ artistId?: string; catalogId?: string; musicVideoId?: string; songId?: string; } & GetMultiDataOptions
MusicKit.Relationship<MusicKit.LibraryArtists>
{ albumId?: string; musicVideoId?: string; songId?: string; } & GetMultiDataOptions
MusicKit.Relationship<MusicKit.LibraryPlaylists>
{ catalogId?: string; } & GetMultiDataOptions
MusicKit.Relationship<MusicKit.LibrarySongs>
{ albumId?: string; catalogId?: string; playlistId?: string; } & GetMultiDataOptions
MusicKit.Relationship<MusicKit.Ratings>
{ ids: string[]; type: MusicKit.AppleMusicAPI.RatingType; }
"none" | "one" | "all"
"off" | "songs"