Eleco is providing the below described support functions, to make it as easy as possible to embed the o2c player and also benefit of future improvements (e.g. support of other OS or browsers) without having to change your website.
A requirement for the use of the library is a link to the script inside your HTML code (This script tag has to be placed prior to the first function call. The script tag is as followed:
<script type="text/javascript" src="http://www.o2c.de/utilities/o2c-utils.js"></script>
Description of the functions
o2cIsInternetExplorer
Example: if (o2cIsInternetExplorer()) ...
Returns true, if the browser is an Internet-Explorer or if the ActiveX version of the o2c player is used.
o2cIsAnyPluginAvailable
Example: if (!o2cIsAnyPluginAvailable()) alert("Sorry");
Returns true, if the browser (possibly after the installation of the plugin) is capable to display o2c objects. Returns false, if no local o2c plugin exists for the browser.
Without a local plugin, you can use the cloud player service.o2cHavePluginVersion
Example: if (o2cHavePluginVersion('2.0.0.68')) ....
Returns true, if the specified version of the plugin is already installed. If not, no automatic update will be triggered.
This function is not available for the ActiveX version (if o2cIsInternetExplorer() returns true). You can query an already created instance of the o2c player for its version with the VersionString function.
o2cRegisterEvent(id, Event, func);
Example: o2cRegisterEvent('thePlayer', 'Click', 'onClick');
Registers an event handler. This object has to be called for all desired events prior to the inserting of the o2c
object itself (o2cInsertObject). The parameters of the function are:
'id' | The HTML id of the o2c object
(must match the first parameter of the o2cInsertObject call). |
'Event' | The name of the o2c events (Click, SubObjectPicked, AnimationDone, AnimationStarted, ObjectLoaded, ThumbnailDone, TextureChanged, MaterialChanged, ObjectMove, ObjectMoving, MouseReleased, ClickWithKeys, MouseDown, MaterialDrageMove, ActivationStateChanged). | 'func' | The event handler function that is to be called. The parameters have to match the event. |
o2cInsertObject(id, vers, width, height, params, alternateImage);
Create an o2c player and return the java script object handle.
Arguments are:
'id' | The HTML id of the o2c object (you can use getElementById() with this ID to get the player handle). |
'vers' | The minimal required version of the player. If the installed version is older, an update will be forced. |
'width' | The width of the player window. |
'height' | The height of the player window. |
'params' | A string encoding all non-default arguments to configure the player. Typically just the URL of the object displayed. |
'alternateImage' | An (optional) image to display if no player is installed |
This function returns the o2c player reference, if a player with the requested minimal version (or newer) is available. If not, a player installation/update is started and null is returned.
Example- Simple use of a single o2c object
<script type="text/javascript" src="http://www.o2c.de/utilities/o2c-utils.js"></script> <script type="text/javascript"> o2c = o2cInsertObject('o2c_id1', '2.0.0.68', 300, 400, 'Zoom="1.129477"; ' + 'PanX="109.219025"; ' + 'PanY="109.512207"; ' + 'ObjectURL="objects/engine.o2c"'); </script>
Example - o2c object with on click alert
<script type="text/javascript" src="http://www.o2c.de/utilities/o2c-utils.js"></script> <script type="text/javascript"> function objectClicked(autoAnimIndex) { alert("Object clicked"); } o2cRegisterEvent('o2c_id1', 'Click', 'objectClicked'); o2c = o2cInsertObject('o2c_id1', '2.0.0.68', 300, 400, 'Zoom="1.129477"; ' + 'PanX="109.219025"; ' + 'PanY="109.512207"; ' + 'ObjectURL="objects/engine.o2c"');