<html>
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"></script>
    <script type="text/javascript" src="http://www.reallusion.com/crazytalk/Unity/samplecode/CTWebPlayer.min.js"></script>
    <script type="text/javascript">
        var player = new CTWebPlayer();
        $(function () {
            player.playerUrl = "http://www.reallusion.com/crazytalk/Unity/samplecode/CTWebPlayer.unity3d";
            player.init($("#unityPlayer"), function () {
                var urls = ["http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Preload2.uctproject",
                               "http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Affirmative.uctidle"];
                player.preLoadFiles(urls, {
                    thread: 2,
                    loaded: function() {
                        console.log("all files are loaded!");
                    }
                });


                player.loadProject("http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Preload.uctproject", {
                    playAfter: 0,

                    idleMotionUrl: "http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Affirmative.uctidle"
                });
            });
        });

        function ChangeProject1() {
            player.loadProject("http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Preload2.uctproject", {
                playAfter: 0,
                idleMotionUrl: "http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode10/Affirmative.uctidle"
            });
        }

    </script>
</head>

<body>
    <table style="text-align:center;margin-left:auto; margin-right:auto;">
        <tr>
            <td>
                <h3>
                    Using the <i>preLoadFiles</i> Function
                </h3>
                <div id="unityPlayer" style="width: 512px; height: 384px;">
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <input type="button" value="Change Project" onclick="ChangeProject1()" class="button" />
            </td>
        </tr>
    </table>
</body>
</html>