var win = Ti.UI.createWindow();
var tableView = Ti.UI.createTableView();
var query = Ti.Media.queryMusicLibrary({
grouping:Ti.Media.MUSIC_MEDIA_GROUP_PLAYLIST,
//grouping:Ti.Media.MUSIC_MEDIA_GROUP_GENRE,
//grouping:Ti.Media.MUSIC_MEDIA_GROUP_COMPOSER,
//grouping:Ti.Media.MUSIC_MEDIA_GROUP_ALBUM,
//grouping:Ti.Media.MUSIC_MEDIA_GROUP_ALBUM_ARTIST,
mediaType:Ti.Media.MUSIC_MEDIA_TYPE_MUSIC
});
if (query.length > 0) {
for (var i=0;i<query.length;i++) {
var tableRow = Ti.UI.createTableViewRow();
var songTitle = Ti.UI.createLabel({
text:query[i].title,
left:10
});
tableRow.add(songTitle);
tableView.appendRow(tableRow);
};
} else {
Ti.API.info('No results.');
}
win.add(tableView);
win.open();
This code has to be tested on a device with music in the device's "iPod". To successfully test the code and find that it's not working, comment out the first "grouping" and uncomment the next one, and you will see the results printed are the exact same, no matter the grouping used.
[Q&A Link](
http://developer.appcelerator.com/question/158348)
No comments