Example #1
0
        public static glTF_VCAST_vci_audio glTF_VCAST_vci_audios_Deserializevci_audios_ITEM(JsonNode parsed)
        {
            var value = new glTF_VCAST_vci_audio();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "name")
                {
                    value.name = kv.Value.GetString();
                    continue;
                }

                if (key == "bufferView")
                {
                    value.bufferView = kv.Value.GetInt32();
                    continue;
                }

                if (key == "mimeType")
                {
                    value.mimeType = kv.Value.GetString();
                    continue;
                }
            }
            return(value);
        }
Example #2
0
        public static void Serialize_vci_audios_ITEM(JsonFormatter f, glTF_VCAST_vci_audio value)
        {
            f.BeginMap();


            if (!string.IsNullOrEmpty(value.name))
            {
                f.Key("name");
                f.Value(value.name);
            }

            if (value.bufferView >= 0)
            {
                f.Key("bufferView");
                f.Value(value.bufferView);
            }

            if (!string.IsNullOrEmpty(value.mimeType))
            {
                f.Key("mimeType");
                f.Value(value.mimeType);
            }

            f.EndMap();
        }
Example #3
0
        public static IEnumerator Import(glTF_VCAST_vci_audio audio, ArraySegment <byte> bytes, Action <AudioClip> callback)
        {
            if (audio.mimeType == "audio/mp3")
            {
                MemoryStream wavStream = null;
                var          task      = Task.Run(() => wavStream = ToWavData(bytes));

                while (true)
                {
                    if (task.IsCompleted || task.IsFaulted || task.IsCanceled)
                    {
                        break;
                    }
                    else
                    {
                        yield return(null);
                    }
                }

                if (wavStream == null)
                {
                    yield break;
                }

                using (wavStream)
                {
                    yield return(CreateClip(wavStream, 0, audio.name, callback));
                }
            }
            else
            {
                using (var wavStream = new MemoryStream(bytes.Array, bytes.Offset, bytes.Count, false, true))
                {
                    yield return(CreateClip(wavStream, bytes.Offset, audio.name, callback));
                }
            }
        }