# cordova-plugin-applemusic

> Cordova Apple Music

Latest version **1.3.3** (published 2018-10-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install cordova-plugin-applemusic
pnpm add cordova-plugin-applemusic
yarn add cordova-plugin-applemusic
bun add cordova-plugin-applemusic
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2018-10-06 |
| First published | 2017-08-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 68 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | khevamann |
| Maintainers | khevamann |
| Keywords | ecosystem:cordova, cordova-ios |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-applemusic
- Repository: https://github.com/khevamann/CordovaAppleMusic
- Homepage: https://github.com/khevamann/CordovaAppleMusic#readme
- Issues: https://github.com/khevamann/CordovaAppleMusic/issues
- npm.io page: https://npm.io/package/cordova-plugin-applemusic

## Recent versions

- 1.3.3 (latest) — 2018-10-06
- 1.3.2 — 2018-10-05
- 1.3.1 — 2018-10-05
- 1.3.0 — 2018-10-05
- 1.2.14 — 2017-10-16
- 1.2.13 — 2017-10-11
- 1.2.11 — 2017-10-11
- 1.2.10 — 2017-10-10
- 1.2.9 — 2017-10-10
- 1.2.8 — 2017-10-04
- 1.2.7 — 2017-10-04
- 1.2.6 — 2017-10-04
- 1.2.5 — 2017-10-04
- 1.2.4 — 2017-10-01
- 1.2.3 — 2017-10-01
- … 29 more at https://npm.io/package/cordova-plugin-applemusic/versions

## README

# CordovaAppleMusic
Access Apple Music from Cordova. This plugin was built to extend zwand19's plugin, and provides other features that the original plugin does not have. Please feel free to ask me any questions you may have.

## Installation

```bash
cordova plugin add cordova-plugin-applemusic
```

## Usage

```js
appleMusic.init((data) => {
      console.log("Plugin Initialized")
    }, (err) => {
      console.log("Error Initializing Plugin")
    })
```

#### Initialize the plugin 
```
appleMusic.init(successFunction, failureFunction)  
```

#### Request Authorization 
```
appleMusic.requestAuthorization(function(isAuthorized){}, failureFunction) 
```

#### Get Play Lists 
```
  appleMusic.getPlayLists(function(playLists){}, failureFunction) 
```  
Return: playLists is an array with each index containing id, name fields; 
   
#### Get Songs 
```
appleMusic.getSongs(playListId, function(songList){}, failureFunction) 
```
Return: songList is an array with each index containing id, name fields; 
 
#### Create Play List with Songs
```
appleMusic.createPlayList(playListName, trackIds, function(status){}, failureFunction) 
```
return: status success on play list creation. 
   
#### Add Single Song to Playlist 
```
appleMusic.addSongstoPlayList(playListId, trackId,  function(status){}, failureFunction) 
```
Return: status success on song addition. 
Arguments: Playlist id, array of track ids 

### Player

#### Play a Track
```
appleMusicPlugin.playTrack(trackId, successFunction, failureFunction)
```
Queues a track by id.

Example id: itunes.apple.com/fr/album/unstoppable/id984653860?i=<b>984653861</b>

The following methods will allow you to manipulate the currently playing track.

#### Get Current Track Duration
```
appleMusicPlugin.getDuration(successFunction, failureFunction)
```
Returns the current track's duration (in seconds)

#### Get Current Track Position
```
appleMusicPlugin.getPosition(successFunction, failureFunction)
```
Returns the current track's position (in seconds)

#### Other Methods
```
appleMusicPlugin.pause(successFunction, failureFunction)

appleMusicPlugin.resume(successFunction, failureFunction)

appleMusicPlugin.seek(seconds, successFunction, failureFunction)

appleMusicPlugin.stop(successFunction, failureFunction)
```

### EVENTS

The following methods will allow you to set up event handlers for the apple music player.

#### Track stopped playing
```
appleMusicPlugin.onStop(callback)
```
Called whenever an apple music track is stopped, interrupted, or paused.

#### Track seeked
```
appleMusicPlugin.onSeek(callback)
```
Called when the user seeks a new position within a track

#### Track started playing
```
appleMusicPlugin.onPlay(callback)
```
Called whenever an apple music track starts playing

---
_Source: https://npm.io/package/cordova-plugin-applemusic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
