Reproduce
1. Create a new projects
2. Add iOS 10 permissions onto your plist on tiapp.xml.
3. Execute this function below:
Titanium.Media.openMusicLibrary({
allowMultipleSelections : false,
mediaTypes : Titanium.Media.MUSIC_MEDIA_TYPE_MUSIC|Titanium.Media.MUSIC_MEDIA_TYPE_ANY_AUDIO,
success : function(event) {
// called when media returned from the MusicLibrary
console.log("Results: " + JSON.stringify(event));
},
cancel : function() {
alert("Aborting ");
},
error : function(error) {
// called when there's an error
var a = Titanium.UI.createAlertDialog({
title : 'Music Library'
});
if (error.code == Titanium.Media.NO_MUSIC_PLAYER) {
a.setMessage('Please run this test on device.');
} else {
a.setMessage('Unexpected error: ' + error.code);
}
a.show();
}
});
4. Log the MusicLibraryResponseType on success
5. Launch the app on device only!
Expected Result
The 'items' attribute will be populated with data.
Actual Result
The 'items' attribute will be an empty dictionary.
Like:
{"items":[{}],"source":{},"types":1,"code":0,"success":true,"type":"success","representative":{}}
So it works on master (6.1.0) for me, need to perform 6.0.1.GA device tests. But
event.items.length
returns 1 for me, the items are just not stringified in the console. I'll get back soon. *EDIT*: Tested with 6.0.1.GA as well, using all kind of configurations (including the one linked here in the tiapp.xml). The items are returned, you can check it by grabbing the title:It was just the log that didn't log all the properties of the media item, which is expected because it is an array of objects. So either iterate over the object keys or just check the [Ti.Media.openMusicLibrary|docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-openMusicLibrary] docs.
Tested with: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.1.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.1.0.v20170120115404 Appcelerator Studio, build: 4.8.1.201612050850 Xcode 8.2 iOS Device: 10 I tested this on an iOS 10 Device, and found that when I selected a song, the object type and the title are printed in the console. I tried this on 2 different songs and saw this in the console:
The output shows that demo code works as expected.