addToMediaCache Method

This command will get a file from the Internet and cache it locally on the device.

intel.xdk.cache.addToMediaCache(url);

Description:

This command will get a file from the Internet and cache it locally on the device. It can then be referenced in a special directory named _mediacache off the root of the bundle. Once this command is run, the “intel.xdk.cache.media.add” event is fired. If there is already a file cached with that name it is overwritten.

Available Platforms:

Parameters:

  • url: The url of the file to cache.

    Events:

  • intel.xdk.cache.media.add: This event is fired once this command is run. It will return an event object that contains the URL of the remote file cached.

    Example:

    
    intel.xdk.cache.addToMediaCache(urlToCache); 
    
    function cacheUpdated(e)
    {
            alert(e.url + " cached successfully");
    }
    document.addEventListener("intel.xdk.cache.media.add", cacheUpdated, false);
               
                
    
For more complete information about compiler optimizations, see our Optimization Notice.