With just a few lines of code your app can access the world's largest lyrics catalog to provide a better experience to your users.
With the Musixmatch extension you can:
- See the synced lyrics for the now playing song in your app
- Read the lyrics for any song directly from your app.
Please refer to the official documentation on Musixmatch.com
- Open the Sample Player App
- Tap the LYRICS button
- Get the Lyrics
Integrating the Musixmatch extension is very easy, just include the following files in your project.
Adding Musixmatch support to your app is easy. To demonstrate how it works, we have demo sample app for iOS that showcase all of the Musixmatch features.
To get started, download the Musixmatch Extension project from https://github.com/Musixmatchdev/musixmatch-app-extension/archive/master.zip, or clone it from GitHub.
Inside the downloaded folder, you'll find the resources needed to integrate with Musixmatch.
Tap on 'Add Music' button to reproduce a song
Tap on 'Lyrics' button and choose Musixmatch (the fist time you ave to enable if from 'More').
You can open Musixmatch whenever you want to show lyrics on time for your nowplaying track. Just give to Musixmatch extension these datas:
- Title
- Artist
- Album
- Artwork
- Current seek time
- Track duration
You can open Musixmatch Extension from your app without any specific UI, it could be standard "Lyircs button" or if you need a specific Musixmatch logo contact us, infos are below.
Add the MXMLyricsAction.h
and MXMLyricsAction.m
to your project and import MXMLyricsAction.h
in your view contoller that implements the action for the lyrics button.
Add lyrics button on your view, you can enable it by check isSystemAppExtensionAPIAvailable
,
Musixmatch Extension is available for every iOS8 devices.
Note that if users doesn't have Musixmatch installed or old version installed without Lyrics Extension the Extension open the AppStore on Musixmatch app page to download/update.
Next we need to wire up the action for this button to this method in your UIViewController:
- (IBAction)lyrics:(id)sender {
MPMediaItem *item = [[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem];
if (item) {
[[MXMLyricsAction sharedExtension] findLyricsForSongWithTitle:item.title
artist:item.artist
album:item.albumTitle
artWork:[item.artwork imageWithSize:artWork.frame.size]
currentProgress:[[MPMusicPlayerController iPodMusicPlayer] currentPlaybackTime]
trackDuration:item.playbackDuration
forViewController:self
sender:sender
competionHandler:^(NSError *error) {
}];
}
}
Data needed in deep:
- Provide a
NSString
for song title. - Provide a
NSString
for song artist name. - Pass a
NSString
for song album name. - Pass an
UIImage
for the view's background (artwork). - Provide a
NSTimeInterval
for the current seek time. - Provide a
NSTimeInterval
for the song duration. - Provide a
UIViewController
from the Extesion can appear. - Provide a completion block that will be called when the user finishes their selection.
As the Extension can't change the Status Bar, there are two possible view styles
- StatusBar White
- StatusBar Black
You can try the two different style by change the 'UISwitch' in the Demo App. Here an example:
StatusBar White
StatusBar Black
If you open up MXMLyricsAction.m and start poking around, you'll be interested in these references.
- Apple Extension Guide
- NSItemProvider, NSExtensionItem, and UIActivityViewController class references.
You can reach us at ios@musixmatch.com, or if you prefer, @musixmatch_api on Twitter.