iTunes.show()

Type function
Return value none
Revision Release 2024.3703
Keywords show, iTunes, picker
See also iTunes
iTunes.play()

Overview

Displays the iTunes library picker and enables you to pick one or more items to play back at a future time.

Syntax

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

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

options (optional)

Table. Table of parameters for the picker — see the next section for details.

Options Reference

The options table may contain 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. The title that appears on the iTunes picker navigation bar. Default is Select song to play.

Example

local iTunes = require( "plugin.iTunes" )

-- Table to store media items
local mediaItems = {}

-- Function that is executed when song playback is complete
local function onPlaybackEnded()
    print( "Playback completed!" )
end

-- Function that is executed after media item(s) have been chosen
local function onMediaChosen( event )

    if ( event.data ) then
        for i=1,#event.data do
            mediaItems[i] = event.data[i]
        end
        
        --play the first item chosen
        iTunes.play( mediaItems[1].url, onPlaybackEnded )

    end 
end

local iTunesOptions =
{
    allowsPickingMultipleItems = true,
    promptTitle = "Select some songs"
}
iTunes.show( iTunesOptions, onMediaChosen )