How can i get the path of music at iphone device.

You must Login before you can answer or comment on any questions.

At the iphone device,there haven't a sdcard as Android,I want develop a musicplayer,but I can't get the path of music at iphone device. Who can help me, Thanks.

1 Answer

var settings = {
    success:function(picked)
    {
        if (!settings.autohide) {
            Ti.API.log("You didn't autohide me!");
            Ti.Media.hideMusicLibrary();
        }
        player.setQueue(picked);
    },
    error:function(error)
    {
        // create alert
        var a = Titanium.UI.createAlertDialog({title:'Music Picker'});
 
        // set message
        if (error.code == Titanium.Media.NO_MUSIC_PLAYER)
        {
            a.setMessage('Please run this test on device');
        }
        else
        {
            a.setMessage('Unexpected error: ' + error.code);
        }
 
        // show alert
        a.show();
    },
    mediaTypes:[Ti.Media.MUSIC_MEDIA_TYPE_ALL],
    autohide:true
};
 
Ti.Media.openMusicLibrary(settings);

— answered 2 years ago by Minh Nguyen
answer permalink
5 Comments
  • Checkout sample code here.

    — commented 2 years ago by Minh Nguyen

  • Very thanks,But I want to get the path of the music by use filesystem,which method I can use. Now this project can not use 'itanium.Media.systemMusicPlayer'.

    — commented 2 years ago by LIU RUIQIANG

  • Where do you want to store music files? Use Ti.Filesystem.getFile to get music file you want to play. In below sample code, music1.wav is under applicationDirectory.

    var music1 = Ti.Filesystem.getFile(Ti.Filesystem.applicationDirectory, 'music1.wav');
    Ti.API.info( music1.nativePath );
    In iOS, you can have many options to store your files:

    • applicationDataDirectory
    • applicationDirectory
    • resourcesDirectory
    • tempDirectory

    Refer to this guide for more information.

    — commented 2 years ago by Minh Nguyen

  • Show 2 more comments

Your Answer

Think you can help? Login to answer this question!