简体   繁体   English

unity 从persistentDataPath 添加mp3 文件

[英]Unity Add mp3 file from persistentDataPath

need your help with turn on mp3 file(with wav and ogg file all is ok) from persistentDataPath in Unity.需要您的帮助来从 Unity 中的persistentDataPath 打开 mp3 文件(带有 wav 和 ogg 文件都可以)。 I have this code to find audio file in persistentDataPath and turn on as AudioClip我有这个代码在persistentDataPath中查找音频文件并作为AudioClip打开

public void StartAudio()
{
    StartCoroutine(PlayAudioClip());
}

IEnumerator PlayAudioClip()
{
    UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(Application.persistentDataPath + "/" + "_song", AudioType.MPEG);
    yield return www.Send();
    //WWW testrequest = new WWW(Application.persistentDataPath + "/" + "_song.mp3");
    if (www.isNetworkError)
        Debug.Log("play error: " + www.error);
    else
    {
        AudioClip audioTrack = DownloadHandlerAudioClip.GetContent(www);
        audio.clip = audioTrack;
        audio.Play();
    }
}

But when I tried to turn on mp3 file I had this error但是当我尝试打开 mp3 文件时出现此错误

Streaming of 'mpeg' on this platform is not supported不支持在此平台上流式传输“mpeg”
UnityEngine.Networking.DownloadHandlerAudioClip:GetContent(UnityWebRequest) UnityEngine.Networking.DownloadHandlerAudioClip:GetContent(UnityWebRequest)

好吧,我又在谷歌上搜索了一段时间并创建了这个qa ,所以它真的很不真实-(

Upgrading Unity to 2020.1.14f1 and above should play mp3 audio clips.将 Unity 升级到2020.1.14f1及更高版本应该可以播放 mp3 音频剪辑。 Unity Answers . 统一答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM