iTunes.stop()

Type function
Return value none
Revision Release 2022.3683
Keywords stop, iTunes
See also iTunes
iTunes.play()
iTunes.pause()
iTunes.resume()

Overview

Stops an item (currently playing or paused) that was selected from the iTunes library.

Syntax

iTunes.stop()

Examples

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 )

        --stop the song
        iTunes.stop()

    end 
end

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