# Titanium.UI.iOS.LivePhotoView

> A view to display a [Titanium.UI.iOS.LivePhoto](https://titaniumsdk.com/docs/sdk/Titanium.UI.iOS.LivePhoto.md) object introduced in iOS 9.1.

- Source: https://titaniumsdk.com/docs/sdk/12.6.1/Titanium.UI.iOS.LivePhotoView
- Titanium SDK version: 12.6.1
- Kind: view
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK iPhone 5.2.0, iPad 5.2.0, macOS 9.2.0
- Extends: Titanium.UI.View
- Inheritance: Titanium.UI.View > Titanium.Proxy

Use the [Titanium.UI.iOS.createLivePhotoView](https://titaniumsdk.com/docs/sdk/Titanium.UI.iOS.md#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](https://developer.apple.com/documentation/photosui/phlivephotoview).

## Example: Basic LivePhotoView

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

``` js
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

- Type: Titanium.UI.iOS.LivePhoto
- Platforms: iPhone, iPad, macOS

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

- Type: Boolean
- Platforms: iPhone, iPad, macOS
- Default: `false`

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.

## Methods

### startPlaybackWithStyle

- Platforms: iPhone, iPad, macOS

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:

- `playbackStyle` (Number): An option for how much of the Live Photo's motion and sound content to play. Default: `Titanium.UI.iOS.LIVEPHOTO_PLAYBACK_STYLE_FULL`.

### stopPlayback

- Platforms: iPhone, iPad, macOS

Ends playback of Live Photo content in the view.

## Events

### start

- Platforms: iPhone, iPad, macOS

Fired when the Live Photo playback starts.

Event properties:

- `playbackStyle` (Number): Returns the `playbackStyle` that was provided to start the playback.

### stop

- Platforms: iPhone, iPad, macOS

Fired when the Live Photo playback stops.

Event properties:

- `playbackStyle` (Number): Returns the `playbackStyle` that was provided to start the playback.

## Inherited members

63 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/12.6.1/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `removeEventListener`
- [Titanium.UI.View](https://titaniumsdk.com/docs/sdk/12.6.1/Titanium.UI.View.md): `accessibilityHidden`, `accessibilityHint`, `accessibilityLabel`, `accessibilityValue`, `add`, `anchorPoint`, `animate`, `animatedCenter`, `backgroundColor`, `backgroundGradient`, `backgroundImage`, `backgroundLeftCap`, `backgroundRepeat`, `backgroundTopCap`, `borderColor`, `borderRadius`, `borderWidth`, `bottom`, `center`, `children`, `clearMotionEffects`, `clipMode`, `convertPointToView`, `getViewById`, `height`, `hide`, `horizontalMotionEffect`, `horizontalWrap`, `id`, `insertAt`, `keypressed`, `layout`, `left`, `opacity`, `previewContext`, `pullBackgroundColor`, `rect`, `remove`, `removeAllChildren`, `replaceAt`, `right`, `rotation`, `show`, `size`, `tintColor`, `toImage`, `tooltip`, `top`, `touchEnabled`, `transform`, `verticalMotionEffect`, `viewShadowColor`, `viewShadowOffset`, `viewShadowRadius`, `visible`, `width`, `zIndex`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

