richpixel / SongPickerANE

A song picker/player AIR native extension for iOS and Android.
27 stars 6 forks source link

songID <-> iOS's iTunesID ? #14

Open moonbahrir opened 7 years ago

moonbahrir commented 7 years ago

Hello, Thank you for this awesome ANE, however I have a problem regarding IDs. When I call the picker with downloadedSongsOnly = false, All my iTunes library can be accessed. When I pick a song from an album, I would like to be able to play the next track of the album after the current song is finished. I have all the info via the iTunes API (artwork for example) but I can't make a call like this: SongPicker.instance.playSong(nextTrackITunesID) because you're using some kind of internal ID which has nothing to do with iTunesID...

Any help would be appreciated ;) Thanks!

richpixel commented 7 years ago

Hi

playSong() is looking for a persistent media ID for the song; MPMediaItemPropertyPersistentID https://developer.apple.com/reference/mediaplayer/mpmediaitempropertypersistentid

Is there any way you can get that ID from your query? It would probably be nice if that function took more properties that could be used to query a specific song, such as title+artist, etc. but that would take some refactoring in the ane.

-rich

On Mon, Jan 9, 2017 at 5:05 AM, moonbahrir notifications@github.com wrote:

Hello, Thank you for this awesome ANE, however I have a problem regarding IDs. When I call the picker with downloadedSongsOnly = false, All my iTunes library can be accessed. When I pick a song from an album, I would like to be able to play the next track of the album after the current song is finished. I have all the info via the iTunes API (artwork for example) but I can't make a call like this: SongPicker.instance.playSong(nextTrackITunesID) because you're using some kind of internal ID which has nothing to do with iTunesID...

Any help would be appreciated ;) Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/richpixel/SongPickerANE/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMlesH3J2x427V2gm2BZXus05j7dYwDks5rQgZqgaJpZM4LeGJS .

moonbahrir commented 7 years ago

I'm not sure what query you're talking about...from the iTunes api? If so I don't think it is possible, I'm double checking this right now and let you know ;)

moonbahrir commented 7 years ago

I didn't found any kind of correlation between these IDs in AS3. :(

richpixel commented 7 years ago

How are you making a call to the iTunes API to retrieve data about the album? I'm not familiar with it...

On Mon, Jan 9, 2017 at 11:46 AM, moonbahrir notifications@github.com wrote:

I didn't found any kind of correlation between these IDs in AS3. :(

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/richpixel/SongPickerANE/issues/14#issuecomment-271336907, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMlevTc76aHwC2e_scXBXsU0dPtDZwQks5rQmRjgaJpZM4LeGJS .

moonbahrir commented 7 years ago

They have two types of searches: https://itunes.apple.com/search?term=jack+johnson and https://itunes.apple.com/lookup?id=909253

I use the first one, with my SongPickerEvent.artist + albumTitle to be the most accurate possible (and "&country=fr" to ask the iTunesStore I want).

The return json is as it follows:

{
 "resultCount":26,
 "results": [

{"wrapperType":"track",
"kind":"song",
"artistId":402914092,
"collectionId":692209301,
"trackId":692209624,
"artistName":"Edi Casabella",
"collectionName":"Préludes des rêves (En attendant l'album) - EP",
"trackName":"J'espère que tu danses",
"collectionCensoredName":"Préludes des rêves (En attendant l'album) - EP",
"trackCensoredName":"J'espère que tu danses",
"artistViewUrl":"https://itunes.apple.com/fr/artist/edi-casabella/id402914092?uo=4",
"collectionViewUrl":"https://itunes.apple.com/fr/album/jespere-que-tu-danses/id692209301?i=692209624&uo=4",
"trackViewUrl":"https://itunes.apple.com/fr/album/jespere-que-tu-danses/id692209301?i=692209624&uo=4",
"previewUrl":"http://a1610.phobos.apple.com/us/r30/Music6/v4/fa/b2/07/fab207d8-1770-faf5-f52b-2a0ad4c42c93/mzaf_7331607619461314658.plus.aac.p.m4a",
"artworkUrl30":"http://is2.mzstatic.com/image/thumb/Music4/v4/a0/37/0c/a0370cff-b6a5-5f8a-2f1b-fe1d7279465d/source/30x30bb.jpg",
"artworkUrl60":"http://is2.mzstatic.com/image/thumb/Music4/v4/a0/37/0c/a0370cff-b6a5-5f8a-2f1b-fe1d7279465d/source/60x60bb.jpg",
"artworkUrl100":"http://is2.mzstatic.com/image/thumb/Music4/v4/a0/37/0c/a0370cff-b6a5-5f8a-2f1b-fe1d7279465d/source/100x100bb.jpg",
"collectionPrice":2.49,
"trackPrice":1.29,
"releaseDate":"2012-01-13T08:00:00Z",
"collectionExplicitness":"notExplicit",
"trackExplicitness":"notExplicit",
"discCount":1,
"discNumber":1,
"trackCount":4,
"trackNumber":1,
"trackTimeMillis":168840,
"country":"FRA",
"currency":"EUR",
"primaryGenreName":"Pop",
"isStreamable":true},
...
]}

The trackID is the ID I'm trying to match with the MPMediaItemPropertyPersistentID...

moonbahrir commented 7 years ago

I think I'm going to develop my own ANE which will do the query in ObjC and return to AS3 the array of IDs (of all tracks of an album/playlist). Therefore I don't need correpondences as the iTunes' trackID won't be needed anymore...

moonbahrir commented 7 years ago

Hi,

I've done some work now and I'm able to retrieve all of the current album's tracks (given album title and artist name), with the good IDs. However I'm having some troubles with the ANE itself, as it is my first, I must do something wrong because it crashes everytime I call my method... Once in a while it doesn't crash, that's how I can tell the fonctionnality works.

Could you please help me with this? I followed this tutorial: http://www.lorenzonuvoletta.com/how-to-create-your-own-ane-for-ios-using-adobe-air/

(we can continue this discussion elsewhere if you want as it is a différent subject...)

I'm closed to something really interesting :)

richpixel commented 7 years ago

Not sure how to do a private message, but if you paste your email address I can delete the comment.

On Thu, Jan 12, 2017 at 12:26 PM, moonbahrir notifications@github.com wrote:

Hi,

I've done some work now and I'm able to retrieve all of the current album's tracks (given album title and artist name), with the good IDs. However I'm having some troubles with the ANE itself, as it is my first, I must do something wrong because it crashes everytime I call my method... Once in a while it doesn't crash, that's how I can tell the fonctionnality works.

Could you please help me with this? I followed this tutorial: http://www.lorenzonuvoletta.com/how-to-create-your-own- ane-for-ios-using-adobe-air/

(we can continue this discussion elsewhere if you want as it is a différent subject...)

I'm closed to something really interesting :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/richpixel/SongPickerANE/issues/14#issuecomment-272226468, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMlenkbtF8zaCbQkK3KcFQeoEA635LWks5rRmIrgaJpZM4LeGJS .

moonbahrir commented 7 years ago

I used autoreleasepool and it seems to be ok :) The last problem I have to resolve (perhaps through my ANE..) is the fact that the music is not played my iPhone main music source (if I plug my headphone and clic on play, Music opens and plays instead of my app)