Skip to content

anatelli10/expo-music-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[wip] expo-music-kit

Note

This project was not touched for many months and the iOS implementation has stopped working. A patch is in the works 🙃.

Apple MusicKit for React Native/Expo. Supports iOS and Web platforms.

Integrates MusicKit on the Web and native MusicKit.

musickitdemo.mov

Usage

Warning

This package is not yet available on npm.

Also, in the current development-only implementation, the Web API is loaded through script injection. This is probably not a great idea for a production application.

From example/App.tsx:

import MusicKit from "expo-music-kit";
import { KJUR } from "jsrsasign";

const developerToken = KJUR.jws.JWS.sign(
	"ES256",
	JSON.stringify({
		alg: "ES256",
		typ: "JWT",
		kid: keyId,
	}),
	JSON.stringify({
		iss: appIdPrefix,
		iat: KJUR.jws.IntDate.get("now"),
		exp: KJUR.jws.IntDate.get("now + 1day"),
	}),
	privateKey,
);

const MUSIC_KIT_JS_CONFIG: MusicKit.Configuration = {
	developerToken,
	app: {
		name: appName,
		build: appBuild,
	},
	bitrate: 256,
};

export default function App() {
	return (
		<View style={styles.container}>
			{/* Wrapper enables MusicKit on the web */}
			<MusicKit.JsProvider configuration={MUSIC_KIT_JS_CONFIG}>
				<Demo />
			</MusicKit.JsProvider>
		</View>
	);
}

API

API
playbackStatus()
isPlaying()
isQueueEmpty()
async signIn()
async signOut()
isAuthorized()
async play()
pause()
async prev()
async next()
shuffleMode()
shuffleModeIndex()
switchShuffleMode()
loopMode()
loopModeIndex()
switchLoopMode()
async queueUp(type: "song" | "album", id: string)
async search(type: "songs" | "albums", searchTerm: string)

Development

MusicKit is not available on the iOS simulator, it can only be tested on an actual iOS device.

About

🎧 Apple MusicKit for React Native/Expo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published