Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

GetManifestResourceStream return null

$
0
0

Can anyone help me take a look on my code and tell what I did wrong? I using the Xam.Plugin.SimpleAudioPlayer to play sound. However when I use GetManifestResourceStream to get the mp3 file it keep return me null. I had put the mp3 file in android Assets file and build action is AndroidAsset.

here the example of my code:

public MainPage()
{
InitializeComponent();

        _simpleAudioPlayer = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
        var beepStream = GetStreamFromFile();
        bool isSuccess = _simpleAudioPlayer.Load(beepStream);
    }

    private void Button_OnClicked(object sender, EventArgs e)
    {
        _simpleAudioPlayer.Play();
    }

    Stream GetStreamFromFile(string filename)
    {
        var assembly = typeof(MainPage).GetTypeInfo().Assembly;

        var stream = assembly.GetManifestResourceStream("beepSound.Android.test.mp3");

        return stream;
    }

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>