public class MediaClient
extends java.lang.Object
The MediaClient is used for loading media resources from Gluon CloudLink into the client application.
Constructor and Description |
---|
MediaClient()
Constructs a new instance of MediaClient with local caching enabled.
|
MediaClient(boolean cachingEnabled)
Constructs a new instance of MediaClient.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isCachingEnabled()
Returns whether the media client has local caching enabled or not.
|
javafx.scene.image.Image |
loadImage(java.lang.String name)
A convenience method to directly load a media resource with the provided name into
a JavaFX
Image object. |
java.io.InputStream |
loadMedia(java.lang.String name)
Load the media resource with the provided name into an InputStream.
|
java.util.ResourceBundle |
loadResourceBundle(java.lang.String bundleName,
java.util.Locale locale)
Loads the resource bundle with the provided bundle name and locale from Gluon CloudLink.
|
public MediaClient()
public MediaClient(boolean cachingEnabled)
cachingEnabled
- true if the response from the media client should be cached in the private storage of
the device platformpublic java.io.InputStream loadMedia(java.lang.String name) throws java.io.IOException
name
- the name of the media resource to loadjava.io.IOException
- if an I/O error occurs while loading the media resource.public javafx.scene.image.Image loadImage(java.lang.String name) throws java.io.IOException
Image
object. You can check Image.errorProperty()
to see whether the returned image contains a valid image or not.name
- the name of the media resource to loadImageView
.java.io.IOException
- if an I/O error occurs while loading the media resource.public java.util.ResourceBundle loadResourceBundle(java.lang.String bundleName, java.util.Locale locale) throws java.io.IOException
null
will be returned instead.bundleName
- the name of the resource bundlelocale
- the locale of the resource bundlejava.io.IOException
- if an I/O error occurs while loading the resource bundle.public boolean isCachingEnabled()
When caching is enabled, calling a media client will cause the locally cached values to be returned if no updates has been made to the data in the cloud. If there is an update, the new data will be downloaded, local cache will be over-written and then returned.
true
if local caching is enabled or false
if it is disabled.