iTunes.stop()

类型 函数
返回值
修订版本 版本 2024.3703
关键词 停止, iTunes
另请参阅 iTunes
iTunes.play()
iTunes.pause()
iTunes.resume()

概述

停止从 iTunes 资料库中选择(当前正在播放或暂停)的项目。

语法

iTunes.stop()

示例

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 )