In this sample, you may use the setVolume and setLoop functions to determine the
audio volume and to turn on the loop feature when you playback the project.
Using the setVolume and setLoop Functions
Controls Behaviors
This sample contains 2 controls, their behaviors are:
Click the button, SetVolume, to set the playback volume to 20%.
Activate the box, Set Loop, to have the project playback
repetitively.
Copy and paste the codes in-between the <head> and
</head>
tags of your custom web page.
The purposes of the functions:
$(function ():
This function defines the address, the position of
the CrazyTalk Web Player in the custom web
and sets the player to play back in loop
mode or not by checking the status of the check box
declared in the body block. It also load and play a
specified default project.
functionsetVolume(): This function
set the audio volume to 20.
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
#ckSetLoop: This is the
id name of the check box
that is defined in the
<body></body> block. It will set the player to loop when the check box is
activated and vice versa. You may change the name to a custom one; however, remember
to give the same name for the check box that will be used to toggle on/off the loop mode
in the body block.
Replace the below address of the *.uctproject file with the ones
where you have uploaded your custom project. https://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode8/Interaction_volume.uctproject
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
<divid="unityPlayer"style="width:640px;height:480px;"></div><inputtype="button"value="SetVolume"onclick="SetVolume()"class="button"/><label><inputid="ckSetLoop"type="checkbox"/>
Set Loop
</label>
Web Player
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.
Controls for Setting Volume and Looping Playback
Copy the
<input.../> line to the position
where you want to embed the button in-between the
<body> and
</body> tags of
your custom web page.
Please note that:
The function and the button that calls it must be
individually put within the head and body blocks in pairs.
The <input.../> line form
one button on the web page. It will call the function declared
within the head block.
Copy the
<label>...</label> lines to the position
where you want to embed the check box and label text in-between the
<body> and
</body> tags of
your custom web page.
Note:
The
id
name, ckSetLoop, must be
identical to the one in the
method of the main function that use it in the head.
Clicking on the check box or the text within the <label></label>
will have the same result - to activate or deactivate the
check box.