iTunes.isPlaying()

Type function
Revision 2014.2468
Keywords isPlaying, iTunes
See also iTunes
iTunes.play()
iTunes.pause()
iTunes.resume()
iTunes.stop()

Overview

Returns a boolean indicating if an item chosen from the iTunes media library is currently playing.

Syntax

iTunes.isPlaying()

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 a song was picked, print its 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 )
            --copy the song table from 'event.data'
            mediaItems[i] = event.data[i]
        end

        print( "Song is playing:", iTunes.isPlaying() )

        --play the first item chosen
        iTunes.play( mediaItems[1].url, onPlaybackEnded )

        print( "Song is playing:", iTunes.isPlaying() )

    end 
end

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