-
Notifications
You must be signed in to change notification settings - Fork 3
Media Functions
This is a collection of media features. I.e. you can show image galleries with a lightbox function or you can make use of an image upload function.
Creates and manages a gallery from image urls.
Supported Platforms
- Android
- iOS
- ChaynsWeb
Table of Contents
Creates a gallery with the provided urls.
Parameter
- id : string - The unique id of the gallery.
- urls : string[] - The image urls.
document.getElementById('#identifier').appendChild(
chayns.ui.gallery.create('MyGallery', ['myImage.jpg'])
);
This method replaces the gallerys urls by the urls in this array and returns true on success.
Parameter
- identifier : string - The id of the gallery.
- urls : string[] - The image urls that will be set for the gallery.
chayns.ui.gallery.setUrls('MyGallery', ['myImage.jpg']);
This method returns an array containing all urls of the gallery (only works if the gallery was created using JavaScript).
Parameter
- id : string - Id of the specific galelry.
Result
- urls : string[] - An array containg all image urls set for the gallery.
chayns.dialog.alert('',
JSON.stringify(chayns.ui.gallery.getUrls('MyGallery'))
);
This method adds an image url to the gallery and returns true on success.
Parameter
- id : string - Id of the gallery.
- url : string - The image url.
chayns.ui.gallery.addUrl('MyGallery', 'myImage.jpg');
Removes the urls of the gallery.
Parameter
- id : string - Id of the gallery.
- url : string - The image url.
chayns.ui.gallery.removeUrl('MyGallery', 'myImage.jpg');
These are useful functions in case you're working with images. You can open images in a lightbox mode or open an upload dialog for images.
Supported Platforms
- Android
- iOS
- ChaynsWeb
The images specified in the url array is shown in gallery mode.
Parameter
- urls : string[] - List of image urls.
- start (optional) : int - If you're providing more than one image, you can specify which image to show at first.
chayns.openImage(['https://tobit.com/chayns/Content/img/chayns_intro.png'], 0);
An Upload-Image-Dialog will be opened. The function allows to upload the image directly from the gallery or use the camera to take a photo. The picture is saved on a server for 24 hours and will be deleted afterwards. The callback-function returns the path of the image.
Result
- url : string - The url to the image saved on our server.
chayns.uploadImage().then(function(data) {
chayns.dialog.alert('Uploaded image to.. ', JSON.stringify(data))
});
These are some additional functions that are using media elements such like video or sound.
Table of Contents
The video specified in the URL is shown in video mode.
Supported Platforms
- Android
- iOS
- ChaynsWeb
Parameter
- url : string - The url referring to the video to show.
chayns.openVideo('https://chayns.tobit.com/medien/locations/378/Videos/510486662298168_1042382722441890_1042382722441890.mp4');
This method allows you to save an appointment to the smarthpone calendar.
Supported Platforms
- Android
- iOS
Parameter
- name : string - The name of the appointment
- location : string - The location of the appointment
- description : string - A description for the appointment
- start : Date - The start date
- end : Date - The end date
var start = new Date(2015, 4, 22, 00, 00, 00);
var end = new Date(2015, 4, 25, 23, 59, 00);
chayns.saveAppointment({
'name': 'Campus-Days',
'location': 'Tobit.Campus, Ahaus',
'description': 'Best time of the year',
'start': start,
'end': end
});
The audio file specified in the URL will be played.
Supported Platforms
- Android
- iOS
Parameter
- url : string - The url referring to the audio file.
- playOnMute (optional) : boolean - The sound will be played even if the user device is muted.
chayns.playSound('https://archive.org/download/testmp3testfile/mpthreetest.mp3');
<!-- To get started.. -->
<!-- Load the chayns API styles and JavaScript from our server -->
<!-- css styles -->
<script src="https://api.chayns-static.space/css/v4/compatibility/compatibility.min.js" version="4.2"></script>
<!-- js api -->
<script src="https://api.chayns-static.space/js/v4.0/chayns.min.js"></script>