# My Problem with Programmer Instrument on Android

**URL:** <https://qa.fmod.com/t/my-problem-with-programmer-instrument-on-android/20441>\
**Category:** Unity\
**Tags:** android\
**Created:** [July 19, 2023, 1:50pm UTC](https://qa.fmod.com/t/my-problem-with-programmer-instrument-on-android/20441 "2023-07-19T13:50:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lezvin](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@Lezvin](https://qa.fmod.com/u/Lezvin)\
**Post date:** [July 19, 2023, 1:50pm UTC](https://qa.fmod.com/t/my-problem-with-programmer-instrument-on-android/20441/1 "2023-07-19T13:50:38Z")

</div>

Hi,  
Version FMOD: 2.01.09  
Version Unity: 2020.3.25f1

I followed the tutorial, and everything works fine in unity editor.  
[https://www.fmod.com/docs/2.00/unity/examples-programmer-sounds.html](https://www.fmod.com/docs/2.00/unity/examples-programmer-sounds.html)

My code of callback is like this:

```auto
        [AOT.MonoPInvokeCallback(typeof(FMOD.Studio.EVENT_CALLBACK))]
        static FMOD.RESULT DialogueEventCallback(FMOD.Studio.EVENT_CALLBACK_TYPE type, IntPtr instancePtr, IntPtr parameterPtr)
        {
            FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);

            // Retrieve the user data
            IntPtr stringPtr;
            instance.getUserData(out stringPtr);

            // Get the string object
            GCHandle stringHandle = GCHandle.FromIntPtr(stringPtr);
            String key = stringHandle.Target as String;

            switch (type)
            {
                case FMOD.Studio.EVENT_CALLBACK_TYPE.CREATE_PROGRAMMER_SOUND:
                    {
                        FMOD.MODE soundMode = FMOD.MODE.LOOP_NORMAL | FMOD.MODE.CREATECOMPRESSEDSAMPLE | FMOD.MODE.NONBLOCKING;
                        var parameter = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure(parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));

                        if (key.Contains("."))
                        {
                            FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
                            exinfo.cbsize = FMOD.MarshalHelper.SizeOf(typeof(FMOD.CREATESOUNDEXINFO));
                            exinfo.suggestedsoundtype = FMOD.SOUND_TYPE.MPEG;

                            var soundResult = FMODUnity.RuntimeManager.CoreSystem.createSound(Application.streamingAssetsPath + "/" + key, soundMode, ref exinfo, out FMOD.Sound dialogueSound);
                            if (soundResult == FMOD.RESULT.OK)
                            {
                                parameter.sound = dialogueSound.handle;
                                parameter.subsoundIndex = -1;
                                Marshal.StructureToPtr(parameter, parameterPtr, false);
                            }
                        }
                        else
                        {
                            var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo(key, out FMOD.Studio.SOUND_INFO dialogueSoundInfo);
                            if (keyResult != FMOD.RESULT.OK)
                            {
                                break;
                            }
                            var soundResult = FMODUnity.RuntimeManager.CoreSystem.createSound(dialogueSoundInfo.name_or_data, soundMode | dialogueSoundInfo.mode, ref dialogueSoundInfo.exinfo, out FMOD.Sound dialogueSound);
                            if (soundResult == FMOD.RESULT.OK)
                            {
                                parameter.sound = dialogueSound.handle;
                                parameter.subsoundIndex = dialogueSoundInfo.subsoundindex;
                                Marshal.StructureToPtr(parameter, parameterPtr, false);
                            }
                        }
                        break;
                    }
                case FMOD.Studio.EVENT_CALLBACK_TYPE.DESTROY_PROGRAMMER_SOUND:
                    {
                        var parameter = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure(parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));
                        var sound = new FMOD.Sound(parameter.sound);
                        sound.release();

                        break;
                    }
                case FMOD.Studio.EVENT_CALLBACK_TYPE.DESTROYED:
                    {
                        stringHandle.Free();

                        break;
                    }
            }
            return FMOD.RESULT.OK;
        }

```

But when I build it to Android, I got this error and play failed:  
Error: [FMOD] FMOD\_OS\_File\_Open : fopen failed to open ‘jar:file:///data/app/com.xxx.xxx.trunk.debug-of2jlBnTOrtH4Ql-1j2uAQ==/base.apk!/assets/Voice/FromAzure/C4A94F9FB0F6A1A1C9CDBD50CF18E4AA.mp3’, errno = 2

I’m sure this file is exist, If anybody know resolve this problem, I would appreciate.

Thanks,

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [July 20, 2023, 3:45am UTC](https://qa.fmod.com/t/my-problem-with-programmer-instrument-on-android/20441/2 "2023-07-20T03:45:19Z")

</div>

Hi,

Unfortunately, we no longer support `2.01`, would it be possible to update to `2.02`? We have [Unity Integration | Tools - Event Reference Updater](https://fmod.com/docs/2.02/unity/tools.html#event-reference-updater) which aids in migrating FMOD major versions.

The issue may be that your application does not have the correct permissions. Are you requesting `Permissions.ExternalRead` ([Unity - Scripting API: Android.Permission.ExternalStorageRead](https://docs.unity3d.com/ScriptReference/Android.Permission.ExternalStorageRead.html)) anywhere in your code? You will also have to add `ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION` to your applications manifest.

Hope this helps!
