Search Unity

The AMF encoding of the arguments cannot exceed 40K.

Discussion in 'Flash' started by atmuc, Oct 25, 2013.

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    when i try to get audio clip from my server via WWW i get this error. my ogg file is 5 K. my code works on editor. after i build and run flash i get following error;
    Code (csharp):
    1.  
    2. ArgumentError: Error #2084: The AMF encoding of the arguments cannot exceed 40K.
    3.     at flash.media::Sound/loadCompressedDataFromByteArray()
    4.     at com.unity::UnityNative$/Ext_Sound_Load()
    5.     at com.unity::UnityNative$/_ZN9AudioClip10InitStreamEP3WWWPvb()
    6.     at com.unity::UnityNative$/WWW_CUSTOM_GetAudioClip()
    7.     at UnityEngine::WWW/WWW_GetAudioClip_Boolean_Boolean_AudioType()
    8.     at UnityEngine::WWW/WWW_GetAudioClip_Boolean_Boolean()
    9.     at UnityEngine::WWW/WWW_GetAudioClip_Boolean()
    10.     at UnityEngine::WWW/get audioClip()
    is it possible to get an audio file in flash?
     
  2. RalphH

    RalphH

    Administrator

    Joined:
    Dec 22, 2011
    Posts:
    592
    Flash cannot load OGG files, but you can load MP3 files.
     
  3. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    when i used following code i get this error;

    i tried 128kbps mono and stereo mp3 file.

    what should i check? my code or my mp3 file?

    Code (csharp):
    1. Streaming of 'mp3' on this platform is not supported
    2. UnityEngine.WWW:GetAudioClip(Boolean, Boolean)
    3. <WaitForAudioClip>c__Iterator1:MoveNext() (at Assets/Scripts/Test.cs:25)

    Code (csharp):
    1. public class Test : MonoBehaviour
    2. {  
    3.     public string url;
    4.     private WWW www;
    5.        
    6.     void Start ()
    7.     {
    8.         url = "http://myserver/Resources/001_003.mp3";
    9.         www = new WWW (url);
    10.         StartCoroutine (WaitForAudioClip ());
    11.     }
    12.    
    13.     void Update ()
    14.     {
    15.         if (audio.clip != null  !audio.isPlaying  audio.clip.isReadyToPlay)
    16.             audio.Play ();
    17.     }
    18.    
    19.     public IEnumerator WaitForAudioClip ()
    20.     {
    21.         yield return www;
    22.         audio.clip = www.GetAudioClip (false, false);
    23.                 //audio.clip = www.GetAudioClip (false, true);
    24.     }
    25. }
     
  4. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    i think last error occurs on Editor not on flash build. Always editor works better than Flash build but in this case Flash build is ok :) so it is better to test editor errors on Flash build.
     
  5. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,162
    this solved audio file problem;

    Code (csharp):
    1. var extension = ".wav";
    2. if (Application.platform == RuntimePlatform.FlashPlayer)
    3.         extension = ".mp3";
    4.  
    5. var url = "http://myserver/Resources/" + audioClipName + extension;
    i found other problem. i did not correctly wait www object to load audio file. i use another code than Test script above and because it is not MonoBehaviour i could not use Coroutine and yield. now i corrected my if status and everything is ok.