Experiences developing my music discovery app for iPhone using Objective-C

 

 

Finally I was able to get a long waited MacBook and started to do something useful with my skills to execute my ideas producing some unique apps to Apple AppStore.

I started coding my algorithms for object recognition and image manipulation using C, but when local competition started to have a app for culture, I decided to participate. So my idea was to list music gigs nearby user location with a possibility to listen music samples and buy tracks from iTunes. Kind of gig promotion app which I could release as free app.

 

There where two such kind of databases available with open API for developers. One was from Bandpage.com and another GigInTown.com. However, they where allowing me to to query only by artist and Bandpage.com even demanded that I must have artist permission to promote them. So, obviously those services where not suitable for me needs.

 

So, I tried Facebook info. Facebook SDK is funny. It demands so many libraries to be included, even high level encryption, SQLLite, Ads, etc to do simple things like authorising user from Facebook account and sending Graph API queries.  I could assume that: either they are incompetent programmers or their modules do much  more that they should.

 

But Facebook API doesn’t allow me to search event by location. You can search places, but not events even they have location co-ordinates in their database. And places where useless information because my query didn’t return Facebook pageID which was documented to find out, is there any music events going on.

 

So, I have to find some other solution. However, I could get a person music likes from Facebook, so I started with that data to write my UI Code. The UI is one simple TableView having controls on footer and  small header. I love simplicity. But to get there, you have to press a login button from first screen because it’s a Facebook demand.

 

When I had to convert Facebook artist names to iTunes search Url, I was looking a ways to do it with NSString. But seems, that sometimes writing something in C will have much less hassles than trying to use Objective-C. Thanks to anyone with their advices how I could do it with NSString.

 

So here is my C function what I wanted to do:

 

NSString *trimArtistNamme ( NSString *name) {

const char *startString;

char endString [name.length+1];

int j = 0;

startString = [name cStringUsingEncoding:NSASCIIStringEncoding];

for (int i=0; i <= name.length; i++) {

if (((startString[i] >= ‘A’) && (startString[i] <= ‘Z’)) || ((startString[i] >= ‘a’) && (startString[i] <= ‘z’)) || ((startString[i] >= ‘0’) && (startString[i] <= ‘9’))) { endString[j] = startString [i]; j++; }

else if (startString [i] == ‘ ‘) { endString [j]= ‘+’; j++; while (startString[i+1] == ‘ ‘) i++; }

}

endString[j] = ”;

return [NSString stringWithCString: endString encoding:NSASCIIStringEncoding];

}

 

The next problem came with AVPlayer class to play iTunes music samples. First I tried it with simple way:

AVPlayer *audioPlayer = [[AVPlayer alloc]

initWithURL:songURL];

if (audioPlayer.error) {

NSLog(@”audio player error”); }

else

[audioPlayer play];

 

then I read somewhere, that I should create an AVPlayerAsset and AVPlayerItem so using a code:

 

AVAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:songURL] options:nil];

AVPlayerItem *anItem = [AVPlayerItem playerItemWithAsset:asset];

 

AVPlayer *audioPlayer = [[AVPlayer alloc]

initWithPlayerItem:anItem];

if (audioPlayer.error) {

NSLog(@”audio player error”); }

else

[audioPlayer play];

 

But this didn’t worked out for me as well.

 

 

Finally, I got very complex code putting a infinite loop until: ( AVPlayerItem.status == VPlayerItemStatusReadyToPlay) && (AVPlayer.status == AVPlayerStatusReadyToPlay)which went to infinite loop.

 

So, after several weeks of tries, I finally gave up and found an open source audio player, which started to work with my first try.

 

So I found nice way to add scrolling text to my table header telling which song from which album is playing and how much they cost using AutoScrollLabel class from Brian Stormont who had declared  in his code that “Permission is granted to use this code free of charge for any project.” Thanks Brian.

 

Posting music likes to Facebook was easiest for me to get work, took only an hour or so and my likes already appeared in my Facebook page.

 

So, I had written a pretty much useless app which takes your favourite artists, let’s listen their song samples, buy songs from iTunes and post a note to his Facebook wall what song you liked.

 

Screen Shot 2013-07-01 at 19.37.43

 

Not much an app near to my objective.

 

So, I added a button that uses Facebook search to find currently playing artist events, puts them to scroll on header and had an attend button, which registers you to that event but I still missed the my unique point.

 

Getting your friends music likes and playing them wasn’t much an innovative idea as well.

 

So, I had to find something else and decided to use a MySql database in my websites account which doesn’t have had much activity recently.

 

So, I ended up an idea to give people music recommendations based on user music taste. So, when I’m sending your music data to my database, I will match them with a people having similar music taste and find those artists that you haven’t yet discovered.

 

And after getting my friends music taste to my database, I was surprised with the results. It really discovered me a good music that I didn’t had found previously. So I got much better results that those music recommendation engines which are using waveform analysis to personalise their music offerings where offering to me. Somehow those big players still think that I’m interested on mainstream music even I haven’t ever even listened any mainstream artist.

 

Programming HTTP POST’s to iOS is little bit more complex that HTTP GET, but for my luck where where good samples in iOS manual.

 

Another problem raised when I tried to use them asynchronously. Somehow my POST’s went some time but stopped then.  First I was thinking that maybe my automatic reference counting mode releases the process but when I found out, that I have generated over 6000 requests it has been probably my server side which stopped taking them. So far it has worked well if you have much less of them.

 

Anyway, I could be more than happy to release my app to public testing but as I still don’t have Apple Developer Account because of lack of bankcard with $99 in it, I can’t do it yet. As it will be free app, my idea is to find a sponsor who could be interested to have their logo in app first screen. Anyone interested, please let me know.

 

Meanwhile, I wrote some gig related code to it as well so when my app will have more users, it can collect the gig info as well and one day could be released as originally planned when my gig database will be big enough.