Forum Visual Studio

Resource.Raw does not contain definition for a file

Hello,

I am trying to read a mp3 file for an Android project.
I am facing an issue where no thread nor documentation helped me, i am suspecting a Vs bug, unless i am missing something in particular ?

Here is my cless where i want to use MediaPlayer :

namespace aaa.bbb.Droid.Custom
{
    public class AudioHelper: IAudioHelper
    {
        public void PlayDepartureSound()
        {
            MediaPlayer mediaPlayer = MediaPlayer.Create(this, Android.Resource.Raw.signal);
            mediaPlayer.Start();
        }
    }
}

The Resource.Designer.cs (namespace = aaa.bbb.Droid) is correctly regenerated each time i delete it,
and it does contain definition for my mp3 file :

public partial class Raw
{

    // aapt resource value: 0x7f070000
    public const int signal = 2131165184;

    static Raw()
    {
        global::Android.Runtime.ResourceIdManager.UpdateIdValues();
    }

    private Raw()
    {
    }
}

Tree view of a part of the project :

And yet, i get this error (in french sorry) :

Erreur CS0117 'Resource.Raw' ne contient pas de définition pour 'signal'

Is there something wrong with my implementation ?
Thank you for your time and sorry for my inacurate english :)

Jordy

Posts

  • prashantvcprashantvc USXamarin Team Xamurai

    This is an issue Android.Resource.Raw.signal, it should be just Resource.Raw.signal or aaa.bbb.Droid.Resource.Raw.signal

    signal is within your app's namespace, not in Android system.

  • djorgridjorgri FRMember

    How did i miss that, this was so obvious !
    It works, thank you a lot for your answer prashantvc :)

Sign In or Register to comment.