In this sample, you may embed the Initial function into your custom web page,
in order to build a CrazyTalk Web Player. After the player is
created, the player will instantly call the loadProject method to load a
CrazyTalk project named Initial.uctproject into the player itself.
Initializing and Loading CrazyTalk Projects
Controls Behaviors
This sample contains only one web player, and its behavior is:
Load a project (Initial.uctproject) as soon as the page is opened.
<scripttype="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><scripttype="text/javascript"src="https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"></script><scripttype="text/javascript"src="https://www.reallusion.com/crazytalk/Unity/samplecode/CTWebPlayer.min.js"></script><scripttype="text/javascript">var player =newCTWebPlayer();
$(function(){
player.playerUrl ="https://www.reallusion.com/crazytalk/Unity/samplecode/CTWebPlayer.unity3d";
player.init($("#unityPlayer"),function(){
player.loadProject("https://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode2/Initial.uctproject");});});</script>
Copy and paste the code in-between the <head> and
</head>
tags of your custom web page.
The purpose of the function:
$(function (): This function
defines the address, the position of the CrazyTalk Web Player
in the custom web
and loads a project (CTWebPlayer.unity3d) without playback.
The adjustable codes in the function: $(function ()
Replace the below address of the CrazyTalk Web Player with the one within your self-hosting
server. https://www.reallusion.com/crazytalk/Unity/samplecode/CTWebPlayer.unity3d
Replace the below address of the *.uctproject file with the one
where you have uploaded your custom project. https://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode2/Initial.uctproject
Note:
These script codes load the custom project file into the player.
If the custom project file is uploaded to the identical server where your custom web
pages are, then simply change the entire address (http://...uctproject) to the file name of the custom
project.
Otherwise, you must replace the entire address with the complete address
(URL) of the custom project file.
Copy and paste the codes from <div>
to </div> into the position
where you want to embed the web player in-between the
<body> and </body>
tags of your custom web page.
Modify the numbers after the width: and
height: parameters in the first line to customize
the size of the player.