# Titanium.UI.iOS.LivePhotoView

A view to display a Titanium.UI.iOS.LivePhoto object introduced in iOS 9.1.

Availability
5.2.0
9.2.0

# Overview

Use the Titanium.UI.iOS.createLivePhotoView method to create an new LivePhotoView.

Specifying either a width or height property for this view will scale its livePhoto with the aspect ratio maintained, up to a maximum size that does not exceed its parent view.

For more infos on Live Photo's, refer to the official Apple documentation (opens new window).

# Examples

# Basic LivePhotoView

The following example shows how to create a simple Ti.UI.iOS.LivePhotoView:

var window = Ti.UI.createWindow({
    backgroundColor: "white"
});

var btn1 = Ti.UI.createButton({
    title: "Select live photo!",
    top: 30
});

btn1.addEventListener("click", openGallery);
window.add(btn1);
window.open();

function openGallery() {
    Ti.Media.openPhotoGallery({
        mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO, Ti.Media.MEDIA_TYPE_LIVEPHOTO],
        success: function(e) {
            var livePhoto = e.livePhoto // Live photo of type Ti.UI.iOS.LivePhoto

            if (livePhoto) {
                var livePhotoView = Ti.UI.iOS.createLivePhotoView({
                    livePhoto: livePhoto,
                    muted: true,
                    width: 300
                });

                livePhotoView.addEventListener("start", function(e) {
                    Ti.API.warn("-- Start playback --");
                    Ti.API.warn(e);
                });

                livePhotoView.addEventListener("stop", function(e) {
                    Ti.API.warn("-- Stop playback --");
                    Ti.API.warn(e);
                });
              window.add(livePhotoView);
            }
        }
    });
}

# Properties

# livePhoto

Availability
5.2.0
9.2.0

The Live Photo displayed in the view.

You receive a new live photo object by selecting an existing photo from the photo gallery. Note: iOS 9.1 only allows to select existing photos from the gallery, capturing new live photos is not supported by the iOS public API, yet.


# muted

Availability
5.2.0
9.2.0
muted :Boolean

A Boolean value that determines whether the view plays the audio content of its Live Photo.

The default value is false, indicating that the view plays audio content along with the motion content of its Live Photo. Change this value to true to play motion content but not audio content.

Default: false

# Methods

# startPlaybackWithStyle

Availability
5.2.0
9.2.0
startPlaybackWithStyle(playbackStyle) void

Begins playback of Live Photo content in the view.

Use the playbackStyle parameter to choose whether to play the full motion and sound content of the Live Photo or only a brief section.

Typically, an app does not need to directly control playback, because a Live Photo view provides interactive playback control. Use this method only when non-interactive playback is appropriate-for example, to briefly animate the content to indicate that a view contains a Live Photo rather than a still image.

Parameters

Name Type Description
playbackStyle Number

An option for how much of the Live Photo's motion and sound content to play.

Returns

Type
void

# stopPlayback

Availability
5.2.0
9.2.0
stopPlayback() void

Ends playback of Live Photo content in the view.

Returns

Type
void

# Events

# start

Availability
5.2.0
9.2.0

Fired when the Live Photo playback starts.

Properties

Name Type Description
playbackStyle Number

Returns the playbackStyle that was provided to start the playback.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.


# stop

Availability
5.2.0
9.2.0

Fired when the Live Photo playback stops.

Properties

Name Type Description
playbackStyle Number

Returns the playbackStyle that was provided to start the playback.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.