Type function Return value none Revision Release 2024.3703 Keywords show, iTunes, picker See also iTunes iTunes.play()
Displays the iTunes library picker and enables you to pick one or more items to play back at a future time.
iTunes.show( onComplete ) iTunes.show( options, onComplete )
Listener. The callback function which is executed after dismissing the iTunes library picker.
Table. Table of parameters for the picker — see the next section for details.
The options
table may contain the following properties:
Boolean. If set to true
, the iTunes picker will allow you to select multiple items to play. Default is false
.
String. The title that appears on the iTunes picker navigation bar. Default is Select song to play.
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 )