buildfire.mediaPreviewer
The fullscreen media preview allows a developer to instantiate a fullscreen images and videos carousel in app. This is to give a better viewing experience to the end user.
Methods
show()
buildfire.mediaPreviewer.showMedia(options, callback)
Displays a full screen images and videos previewer
buildfire.mediaPreviewer.show(
{
media: [
// video
{
width: 1920,
height: 1080,
videoSrc: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
videoPosterSrc: 'https://picsum.photos/1920/1080',
},
// image
{
width: 1080,
height: 1920,
imageSrc: 'https://picsum.photos/1080/1920',
},
],
index: 0,
enableDownload: true,
downloadPermissionRequestButtonText: 'Open settings',
downloadPermissionDeniedMessage: 'Permission denied',
},
(error, result) => {
console.log(
'Media previewer closed'
);
}
);
options
Name | Type | Required | Description | Default |
---|---|---|---|---|
media | [object] | yes | Array of media objects to be displayed in full screen | |
index | number | no | Index of media to start carousel from | 0 |
enableDownload | boolean | no | Enable download button, allows the user to download the media to device gallery | false |
downloadSuccessMessage | string | no | Download success message to be displayed in a toast message | Media downloaded successfully |
downloadErrorMessage | string | no | Download error message to be displayed in a toast message | Failed to download media |
downloadPermissionDeniedMessage | string | no | Error message to be displayed when save media permission is denied (iOS only) | Download to Photos denied |
downloadPermissionRequestButtonText | string | no | Button text that navigates to app settings, shown along side downloadPermissionDeniedMessage (iOS only) | Settings |
info
If the native download feature is not present on device, the download button will not be shown
media
Name | Type | Required | Description | Default |
---|---|---|---|---|
width | number | no | The width of the provided media | |
height | number | no | The height of the provided media | |
videoSrc | string | yes if media type is a video | Video URL to be displayed | |
imageSrc | string | yes if media type is an image | Image URL to be displayed | |
videoPosterSrc | string | no, if the video has a poster image | Video poster to be displayed before the video is played |
info
Video media requires a videoSrc
, while image media requires imageSrc
caution
If video media does not have videoPosterSrc
it may not show a poster (video image) on iOS or Android. However, a video may accept #t=[start time]
, example: https://[video source]#t=0.1
callback()
Callback function that gets called when carousel is closed