In this sample, you may use the preLoadFiles function to load project and idle motion files
in multiple threads. You will experience the advantage of pre-loading files in this web player. Click the buttons to change the project
for the left and right players of this page, you will see that the left one shows the other
project sooner because it loads the new project when it is playing;
while the right player takes more waiting time to load the same project.
Using the preLoadFiles Function
Using the preLoadFiles Function
This sample contains two players with two buttons, the behaviors of the two
Click the left button, Change Project, to play back the
pre-loaded project (Preload2.uctproject) in the left
The actor will have a pre-loaded idle motion (Affirmative.uctidle) as well.
Click the right button, Change Project, to begin loading the second project (Preload2_1.uctproject) and idle motion (Affirmative1.uctidle)
for the actor. The right player must wait for the files to be completely
loaded before starting to play.
Copy and paste the codes in-between the <head> and
tags of your custom web page.
The purposes of the functions:
$(function (): This
function defines the addresses, the positions of two CrazyTalk Web Players in the custom web
and loads and auto plays a default project (Preload.uctproject);
meanwhile, the first player also loads two more files (Preload2.uctproject, Affirmative.uctidle) behind the scenes as it is playing the default project.
functionChangeProject1(): This function
loads and plays the preloaded project and assigns
idle motion to its actor.
The adjustable code in the functions: $(function ()
Replace the below address of the CrazyTalk Web Player with the one within your self-hosting
Replace the below address of the *.uctproject file with the one
where you have uploaded your custom project. http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Preload.uctproject
If the custom actor files are uploaded to the identical server where your custom web
pages are, then simply change the entire
addresses (http://...uctmodel) to
the file names of the custom actors.
Otherwise, you must replace the
entire addresses with the complete addresses
(URL) of the custom actor files.
playAfter: The value determines the seconds for the player
to wait before starting play the true content of the project.
A negative value means not to play back after the project is loaded.
var urls: This line declares a new array
in which multiple addresses are stored. In
this case, there is one project and one idle motion
file: http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Preload2.uctproject http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Affirmative.uctidle
You may replace the original
addresses with custom ones you want to preload.
thread: The number after this parameter determines the number of the files in the array
for preloading at once. You may increase the number
to preload more files simultaneously, however more files in pre-loading means more data bandwidth will be required.
Replace the below addresses of the *.uctproject
and *.uctidle files with the identical ones you have
specified to be preloaded in previous code. http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Preload2.uctproject http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Affirmative.uctidle
Please note that because the files are pre-loaded into the cache of the browser,
it will instantly play the project without re-loading it from the specified
which decreases the waiting time before the project playback.
playAfter: This value determines the seconds for the player
to wait before starting play the true content of the
A negative value means not to play back.