Developers

Open Song

Not only can ye use th’ onsong:// URL scheme t’ import content into OnSong, but ye can also use it t’ view specific songs in yer library. Since this be a URL scheme, it will result in openin’ OnSong and bringin’ it t’ th’ foreground if it be not already bein’ viewed. If ye be viewin’ OnSong usin’ a split screen or other multitaskin’ configuration on an iPad, it will remain this way. That makes URL open actions ideal fer use if yer app be runnin’ in a portion o’ th’ iPad screen, matey.

Requirements

Th’ Open Song URL API requires th’ current version o’ OnSong. Ye can join our beta team t’ get pre-release versions o’ OnSong fer testin’. Since th’ onsong:// URL scheme be used on every version o’ OnSong, ye’ll want t’ ensure ye only have th’ beta version installed t’ avoid conflict with other versions o’ th’ app, savvy?

Checkin’ Installation

O’ course t’ use any o’ these API calls, ye’ll need t’ ensure th’ user has OnSong installed on their device. T’ do this, add onsong as a registered URL scheme. Without this, yer app will not be able t’ open OnSong scheme. However this does not apply t’ web-based apps.

Once registered, ye can use th’ [UIApplication canOpenURL:] method t’ determine if th’ URL can be opened. If that returns false, then th’ OnSong app be not installed and ye can present an appropriate user interface t’ have th’ user install OnSong. Fer instance, through an affiliate link. Ye can request t’ become an affiliate partner with OnSong by emailin’ us.

View Song

Th’ simplest action be t’ open a song. OnSong can do this by either searchin’ by song title, or by song identifier. This uses th’ base action path and th’ song querystring parameter. T’ open th’ song Be Still, we’d use this:

onsong://open/songs?song=be-still

Alternately, we could pass a known unique identifier fer th’ song querystring parameter like so:

onsong://open/songs/?song=85F0CE06-7414-4FFB-BFF0-14D3507A1AA7

View Collection

Collections in OnSong include books but also th’ standard collections like All Songs and Unbound Songs. Ye can load th’ All Songs collection into th’ song viewer usin’ th’ collection querystring parameter like this:

onsong://open/songs/?collection=all-songs

Alternately, ye can load th’ contents o’ a book in th’ same way:

onsong://open/songs/?collection=christmas-songs

View Set

Sets in OnSong be used t’ perform songs fer a specific gig, matey. URL actions let ye either load an existin’ set, or create new ones. We will start by simply viewin’ th’ current set like this:

onsong://open/songs/?set=current-set

Navigation

Of course loadin’ a set be incredibly helpful, but what if we want t’ navigate through th’ set? Usin’ th’ index querystring parameter, we can move through th’ currently viewed songs whether they be in a collection or set, ye scallywag.

T’ move t’ th’ first song, we can use th’ first value:

onsong://open/songs?index=first

Or just as easy, sail t’ th’ last song in th’ song viewer:

onsong://open/songs?index=last

Or wherever we be, we can just sail t’ th’ next song in th’ song viewer:

onsong://open/songs?index=next

Or sail back t’ th’ previous one:

onsong://open/songs?index=previous

Or sail t’ any song usin’ its numeric index, th’ first song bein’ at index zero. T’ go t’ th’ second song in th’ set, we’d use:

onsong://open/songs?index=1

Pullin’ Songs

Arrr, this be where things get slightly crazy, or as developers would say more “powerful”. We can use this same API t’ load multiple songs into th’ viewer by repeatin’ th’ song querystring parameter. We can then take those songs and load them into th’ current set, or create a new set.

T’ view multiple songs and not save it, we just use th’ song parameter multiple times in th’ order we want them t’ appear, includin’ an optional index parameter if we don’t want t’ start at th’ beginnin’ o’ th’ set:

onsong://open/songs/?song=be-still&song=beautiful-life&song=changes&index=1

T’ add these songs t’ th’ currently viewed set, we pass th’ set parameter with th’ name o’ th’ set we want t’ create:

onsong://open/songs/?song=be-still&song=beautiful-life&song=changes&set=New+Set

Or we can load it into th’ current set usin’ th’ current value fer th’ set parameter:

onsong://open/songs/?song=be-still&song=beautiful-life&song=changes&set=current

Arrr, of course we can also use a name t’ load th’ song into a named set, or use th’ set’s unique identifier if it be known. Here we add a known song into a known set at th’ fourth position:

onsong://open/songs/?song=85F0CE06-7414-4FFB-BFF0-14D3507A1AA7&index=3&set=8DD5B78C-205A-4F6E-AD09-63711F372BD3

Exportin’ Songs

But how would ye know th’ unique identifiers t’ call in an individual’s library? Th’ OnSong URL Action API gives ye an export function. T’ export values, ye let th’ API know what t’ export (song, set, collection) and then where t’ send that data. Fer instance:

onsong://export/songs?collection=current&returnURL=http%3A%2F%2Fmywebsite%2Ecom%2Freceive%3Fdata%3D

In th’ above example, OnSong will take th’ currently loaded collection in th’ song viewer, create a list o’ song content, and generate Base64 encoded data, appendin’ it t’ th’ provided returnURL parameter. In this case, we’ve used http://mywebsite.com/receive?data= so th’ data will be sent t’ th’ end o’ that URL. Of course ye could just as easily make this a URL scheme that opens yer app and passes th’ song list as well.

While th’ data be encoded fer easy transmission, once decoded th’ list format be a very simple tab-delimited list. Th’ properties that be listed be contained in th’ first row, with each song appearin’ t’ precedin’ rows delimited by a newline character. This means ye can split th’ content by newline, then by tabs, usin’ th’ first line t’ describe th’ data in each o’ th’ columns.

We can also specify th’ properties that we want t’ export, savvy? By default, OnSong will export th’ song’s ID, title and artist. However we could also export th’ key, transposed key, capo and more.