Code:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Media;
using Android.Graphics;
namespace MGTOW
{
[Activity(Label = "MGTOW", MainLauncher = true, Icon = "@drawable/MGTOW")]
public class MainActivity : Activity
{
bool x = true;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
MediaPlayer _myPlayer = MediaPlayer.Create(this, Resource.Raw.zimbabue);
_myPlayer.Looping = true;
_myPlayer.Start(); // to start song
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate {
if (x)
{
http://_myPlayer.Pause();
_myPlayer.Stop();
_myPlayer.Prepare();
x = false;
button.Text = "play";
}
else
{
_myPlayer.Start();
x = true;
button.Text = "pause";
}
};
}
}
}
see book :
https://www.yotamarker.com/t122-xamarin-c-2017-grimoir-the-book
for beginner information.