[TIMOB-24372] iOS: Expose all missing MediaItem properties, allow Apple Music playback in Ti.Media.AudioPlayer
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2017-04-06T13:49:28.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.1.0 |
| Components | iOS |
| Labels | n/a |
| Reporter | Ricardo Ramirez |
| Assignee | Hans Knöchel |
| Created | 2017-02-04T03:27:16.000+0000 |
| Updated | 2017-04-12T12:10:47.000+0000 |
This is not how the iOS music picker works. We *can* expose the
assetURLproperty to the Titanium API, but that looks for example like this:Simply, because Apple does not allow the developer to grab music files from the music library to send them somewhere else (piracy, privacy-settings, ...). So yes, we can expose it, but they rather want to use the meta-data to loookup the song on Spotify / Apple Music and link that to the app, like Shazam does for example. Or, if they want to play the music, they should use the [Ti.Media.MusicPlayer](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.MusicPlayer) to playback songs in a self-defined queue. Please advice what they want to do. *EDIT*: Side-note, this are all properties we could expose from the native API (we already have lots of them but iOS 8+ added tons more):PR (exposing *all* missing properties to be future-safe): https://github.com/appcelerator/titanium_mobile/pull/8817 Note: Please still read the above comment. If they expect to receive an URL of a file that they can send, they won't succeed. This is - once again - restricted by Apple's privacy settings. Test-Case:
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var btn = Ti.UI.createButton({ title: 'Open Music Library' }); btn.addEventListener('click', function() { Ti.Media.openMusicLibrary({ error: function(e) { Ti.API.error('Error opening the music library: Check if permissions granted and ensure to run on device!'); }, success: function(e) { var item = e.items[0]; // Some of the media item properties. Check the docs for more! Ti.API.info('Title: ' + item.title); Ti.API.info('Artist: ' + item.artist); Ti.API.info('Album: ' + item.albumTitle); Ti.API.info('Has Protected Asset: ' + item.hasProtectedAsset); if (!item.hasProtectedAsset) { Ti.API.info('Asset URL: ' + item.assetURL); } Ti.API.info('Is Explicit: ' + item.isExplicit); Ti.API.info('Date Added: ' + item.dateAdded); } }) }); win.add(btn); win.open();Verified as fixed, tested with demo code provided in JIRA ticket, including additional exposed media item properties. iOS 10.2 & 9.3. Tested On: iPhone 7 10.2.1 Device iPhone 5S 9.3.5 Device Mac OS Sierra (10.12.2) Ti SDK: 6.1.0.v20170410104407 Appc Studio: 4.8.1.201701192045 Appc NPM: 4.2.9-1 App CLI: 6.1.0 Xcode 8.2.1 Node v4.6.0 *Closing ticket.*