iTunes.show()

Type function
Library PLUGIN_NAME.*
Return value [TYPE][api.type.TYPE]
Revision 2014.2382
Keywords
Sample code
See also

Overview

Displays the iTunes library picker and enables you to pick one or more items to playback at a later date.

Syntax

iTunes.show( onComplete )
iTunes.show( options, onComplete )
onComplete (required)

Listener. The callback function that is executed after dismissing the iTunes library picker.

options (optional)

Table. Table of parameters. See Format for options below.

Format for options

The options table contains the following properties:

allowsPickingMultipleItems (optional)

Boolean. If set to true, the iTunes picker will allow you to select multiple items to play. Default is false.

promptTitle (optional)

String. This is the title that appears on the iTunes picker navigation bar. Default is "Select song to play"

Examples

-- Require the iTunes library
local iTunes = require( "CoronaProvider.plugin.iTunes" )
local widget = require( "widget" )


-- Function that gets executed after media item(s) have been chosen
local function onMediaChosen( event )
    -- If a song was picked, print it's details
    if event.data then
        for i = 1, #event.data do
            print( "url", event.data[i].url )
            print( "album artist", event.data[i].albumArtist )
            print( "album title", event.data[i].albumTitle )
            print( "song title", event.data[i].songTitle )
            print( "performing artist", event.data[i].performingArtist )
            print( "composer", event.data[i].composer )
            print( "genre", event.data[i].genre )
            print( "lyrics", event.data[i].lyrics )
            print( "podcast title", event.data[i].podcastTitle )
        end
    end 
end


-- Function to show the iTunes picker
local function showItunesLibrary()
    -- Options to pass to iTunes.show
    local options =
    {
        allowsPickingMultipleItems = true,
        promptTitle = "Select some songs!",
    }

    -- Show the users iTunes library
    iTunes.show( options, onMediaChosen )
end


-- Button to show the picker
local showPicker = widget.newButton
{
    label = "Show Picker",
    onRelease = showItunesLibrary,
}
showPicker.x = display.contentCenterX
showPicker.y = stopButton.y + ( showPicker.contentHeight + 45 )