Created
November 5, 2019 10:55
-
-
Save mlopezr/b004c48691470314f6505312849a276f to your computer and use it in GitHub Desktop.
VideoPlayer with auto-hiding overlay in APL 1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "APL", | |
"version": "1.1", | |
"import": [ | |
{ | |
"name": "alexa-layouts", | |
"version": "1.1.0" | |
} | |
], | |
"mainTemplate": { | |
"parameters": [ | |
"payload" | |
], | |
"items": [ | |
{ | |
"type": "Container", | |
"direction": "column", | |
"height": "100vh", | |
"width": "100vw", | |
"items": [ | |
{ | |
"type": "TouchWrapper", | |
"id": "videoWideToggleButton", | |
"width": "100vw", | |
"height": "100vh", | |
"items": [ | |
{ | |
"type": "Video", | |
"id": "videoPlayer", | |
"width": "100vw", | |
"height": "100vh", | |
"autoplay": true, | |
"audioTrack": "foreground", | |
"source": { | |
"url": "https://alexa-radio-cow.s3.amazonaws.com/Driving_timelapse_CCBY_NatureClip.mov" | |
}, | |
"onPause": [ | |
{ | |
"type": "SetState", | |
"componentId": "alexaPlayPauseToggleButton", | |
"state": "checked", | |
"value": true | |
}, | |
{ | |
"type": "SetState", | |
"componentId": "videoWideToggleButton", | |
"state": "checked", | |
"value": true | |
}, | |
{ | |
"type": "SetValue", | |
"componentId": "overlayContainer", | |
"property": "display", | |
"value": "normal" | |
} | |
], | |
"onPlay": [ | |
{ | |
"type": "SetState", | |
"componentId": "alexaPlayPauseToggleButton", | |
"state": "checked", | |
"value": false | |
}, | |
{ | |
"type": "SetState", | |
"componentId": "videoWideToggleButton", | |
"state": "checked", | |
"value": false | |
}, | |
{ | |
"type": "SetValue", | |
"componentId": "overlayContainer", | |
"property": "display", | |
"value": "normal" | |
}, | |
{ | |
"type": "SetValue", | |
"componentId": "overlayContainer", | |
"property": "display", | |
"value": "invisible", | |
"delay": "3000" | |
} | |
] | |
} | |
], | |
"onPress": [ | |
{ | |
"type": "SetState", | |
"componentId": "alexaPlayPauseToggleButton", | |
"state": "checked", | |
"value": "${!event.source.value}" | |
}, | |
{ | |
"type": "SetState", | |
"componentId": "videoWideToggleButton", | |
"state": "checked", | |
"value": "${!event.source.value}" | |
}, | |
{ | |
"when": "${event.source.value}", | |
"type": "ControlMedia", | |
"componentId": "videoPlayer", | |
"command": "play" | |
}, | |
{ | |
"when": "${!event.source.value}", | |
"type": "ControlMedia", | |
"componentId": "videoPlayer", | |
"command": "pause" | |
} | |
] | |
}, | |
{ | |
"type": "Container", | |
"id": "overlayContainer", | |
"position": "absolute", | |
"width": "100vw", | |
"height": "100vh", | |
"alignItems": "center", | |
"items": [ | |
{ | |
"type": "Text", | |
"text": "Title", | |
"width": "100vw", | |
"fontSize": "8vh", | |
"paddingTop": "3vh", | |
"paddingLeft": "3vh" | |
}, | |
{ | |
"type": "Text", | |
"text": "Description", | |
"width": "100vw", | |
"fontSize": "5vh", | |
"paddingTop": "1vh", | |
"paddingLeft": "3vh" | |
}, | |
{ | |
"type": "AlexaTransportControls", | |
"position": "absolute", | |
"bottom": "0", | |
"autoplay": true, | |
"primaryControlSize": "10vh", | |
"secondaryControlSize": "10vh", | |
"mediaComponentId": "videoPlayer", | |
"playPauseToggleButtonId": "alexaPlayPauseToggleButton" | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To test this APL layout:
Relevant documentation: