We’ve added some media goodies to the latest daily builds! The following are available as of 2013.1244.

Videos (and Photos)

In the latest daily builds, you now have the ability to select and capture videos. Instead of adding even more complexity to media.show(), we decided it was time to deprecate that function in favor of newer and cleaner APIs.

Our goal here was to distinguish between selecting media versus capturing media. In both cases, a native UI provided by the OS is presented.

To select a video, simply call the new media.selectVideo() function and the native UI interface for selecting a video from the device’s catalog comes up:

local function onComplete(event)
    if event.completed then
        media.playVideo(event.url)
    end
end

if media.hasSource( media.PhotoLibrary ) then
   media.selectVideo( { listener = onComplete )
end

Similarly, you can present an interface to capture video using media.captureVideo():

local function onComplete(event)
    if event.completed then
        media.playVideo(event.url)
    end
end

if media.hasSource( media.Camera ) then
    media.captureVideo( { listener = onComplete } )
end

We also created similar functions for photos: media.selectPhoto() and media.capturePhoto(). We recommend you use these instead of the deprecated “media.show()”:

Accessing/Playing the iTunes Library

With the new iTunes plugin, you’ll be able to access the iTunes library and play songs from them:

The “iTunes.show()” allows you to pick music from the iTunes library, which you can then play using “iTunes.play()”.

The full documentation is available here.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>