
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@soundxyz/react-native-apple-music
Advanced tools
A react native module for the Apple MusicKit ( iOS )
An Example project was developed to exercise and test all functionality within this library. If you are curious about how to use something, or need to compare your application setup to something that works, check there first.
The following table shows the platform support for various Apple Music functionality within this library.
Feature | iOS |
---|---|
Auth | |
authorize | ✅ |
checkSubscription | ✅ |
Player | |
play | ✅ |
pause | ✅ |
togglePlayerState | ✅ |
skipToNextEntry | ✅ |
getCurrentState | ✅ |
addListener | ✅ |
removeListener | ✅ |
MusicKit | |
catalogSearch | ✅ |
getTracksFromLibrary | ✅ |
setPlaybackQueue | ✅ |
npm install @lomray/react-native-apple-music
platform :ios, 15.0
npx pod-install
<key>NSAppleMusicUsageDescription</key>
<string>Allow to continue</string>
As of React Native > 0.61
, auto linking should work for iOS. There shouldn't be any modifications necessary and it Should work out of the box.
The @lomray/react-native-apple-music
package provides a set of tools to interact with Apple MusicKit in your React Native application. Here's how to get started:
First, import the necessary modules from the package:
import {
Auth,
Player,
MusicKit,
useCurrentSong,
useIsPlaying,
} from '@lomray/react-native-apple-music';
Before accessing Apple Music data, you need to authenticate the user and obtain permissions:
async function authenticate() {
try {
const authStatus = await Auth.authorize();
console.log('Authorization Status:', authStatus);
} catch (error) {
console.error('Authorization failed:', error);
}
}
Check if the user has an active Apple Music subscription:
async function checkSubscription() {
const subscriptionStatus = await Auth.checkSubscription();
console.log('Subscription Status:', subscriptionStatus);
}
Control playback using the Player module:
// Play music
Player.play();
// Pause music
Player.pause();
// Toggle between play and pause
Player.togglePlayerState();
// Skip to the next song
Player.skipToNextEntry();
Get the current playback state and listen for changes:
Player.getCurrentState().then(state => {
console.log('Current Playback State:', state);
});
// Listen for playback state changes
const playbackListener = Player.addListener('onPlaybackStateChange', state => {
console.log('New Playback State:', state);
});
// Don't forget to remove the listener when it's no longer needed
playbackListener.remove();
To maintain optimal performance and prevent memory leaks, it's important to manage your event listeners effectively. Here's how you can add and remove listeners using the Player
class.
const playbackListener = Player.addListener('onPlaybackStateChange', state => {
console.log('New Playback State:', state);
});
// This will remove all listeners for 'onPlaybackStateChange' event
Player.removeAllListeners('onPlaybackStateChange');
Search the Apple Music catalog:
async function searchCatalog(query) {
try {
const types = ['songs', 'albums']; // Define the types of items you're searching for. The result will contain items among songs/albums
const results = await MusicKit.catalogSearch(query, types);
console.log('Search Results:', results);
} catch (error) {
console.error('Search failed:', error);
}
}
Get a list of recently played items:
async function getTracksFromLibrary() {
try {
const results = await MusicKit.getTracksFromLibrary();
console.log('User`s library Results:', results);
} catch (error) {
console.error('Getting user tracks failed:', error);
}
}
Load a system Player with Song, Album, Playlist or Station, using their ID:
async function setPlaybackQueue() {
try {
await MusicKit.setPlaybackQueue("123456", "album");
} catch (error) {
console.error('Setting playback queue:', error);
}
}
The package provides hooks for reactive states in your components:
import React from 'react';
import { View } from 'react-native';
import { useCurrentSong, useIsPlaying } from '@lomray/react-native-apple-music';
function MusicPlayerComponent() {
const { song } = useCurrentSong();
const { isPlaying } = useIsPlaying();
return (
<View>
{isPlaying ? 'Playing' : 'Paused'} - {currentSong?.title || 'No song playing'}
</View>
);
}
Bug or a feature request, please open a new issue.
Made with 💚
Published under Apache License.
FAQs
Apple MusicKit for React-Native
The npm package @soundxyz/react-native-apple-music receives a total of 14 weekly downloads. As such, @soundxyz/react-native-apple-music popularity was classified as not popular.
We found that @soundxyz/react-native-apple-music demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.