'Xamarin MediaManager: No sound after installing my application from Google Play Console internal testing
I have no sound when I open my application right after installing it on my Android phone. But when I quit my application and reopen it then the sound works normally.
Why is there no sound when I open the application the very first time on my phone?
I only call CrossMediaManager.Current.Init(this); once in OnCreate located in my Activity1.cs.
protected override void OnCreate(Bundle bundle)
{
base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(bundle);
Xamarin.Forms.Forms.Init(this, bundle);
Xamarin.Essentials.Platform.Init(this, bundle);
CrossMediaManager.Current.Init(this);
if (Intent.Extras != null)
{
foreach (var key in Intent.Extras.KeySet())
{
var value = Intent.Extras.GetString(key);
Log.Debug(TAG, "Key: {0} Value: {1}", key, value);
}
}
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager.DefaultDisplay.GetRealMetrics(displayMetrics);
int w1 = displayMetrics.WidthPixels;
int h1 = displayMetrics.HeightPixels;
_game = new Game1(w1, h1);
_game.Run();
}
In addition, I play my songs like this(in another class):
if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.Android)
{
string androidfilename = "file:///android_asset/" + songfilename;
await CrossMediaManager.Current.Play(androidfilename);
}
I use nuget package Plugin.MediaManager (1.1.0).
I created an issue on github: https://github.com/Baseflow/XamarinMediaManager/issues/855
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
