本文整理汇总了C#中Android.Media.MediaPlayer.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Pause方法的具体用法?C# MediaPlayer.Pause怎么用?C# MediaPlayer.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.Pause方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
ActionBar.Hide();
SetContentView(Resource.Layout.Main);
cover = FindViewById<RelativeLayout>(Resource.Id.titleScreen);
player = MediaPlayer.Create(this, Resource.Raw.avril_14th);
toggleMusic = FindViewById<ToggleButton>(Resource.Id.toggleMusic);
player.Start();
player.Looping = true;
cover.Click += delegate
{
StartActivity(typeof(Login));
};
toggleMusic.Click += (o, s) =>
{
if (toggleMusic.Checked)
{
player.Start();
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);
}
else
{
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
player.Pause();
}
};
}
示例2: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.HomeScreen, container, false);
infoButton = view.FindViewById<Button>(Resource.Id.infoButton);
player = MediaPlayer.Create(view.Context, Resource.Raw.avril_14th);
toggleMusic = view.FindViewById<ToggleButton>(Resource.Id.toggleMusic);
cover = view.FindViewById<RelativeLayout>(Resource.Id.titleScreen);
Xamarin.Insights.Initialize(XamarinInsights.ApiKey, view.Context);
CurrentPlatform.Init();
player.Start();
player.Looping = true;
cover.Click += delegate
{
facebookLogin.Invoke(this, new LoginEventArgs());
};
toggleMusic.Click += (o, s) => {
if (toggleMusic.Checked)
{
player.Start();
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);
}
else {
toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
player.Pause();
}
};
return view;
}
示例3: OnPause
public void OnPause(MediaPlayer player)
{
player.Pause();
}
示例4: OnCreate
protected async override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.PodcastDetail);
var showNumber = Intent.GetIntExtra("show_number", 0);
episode = Activity1.ViewModel.GetPodcast(showNumber);
var description = FindViewById<TextView>(Resource.Id.descriptionView);
description.Text = episode.Description;
var play = FindViewById<Button>(Resource.Id.playButton);
var pause = FindViewById<Button>(Resource.Id.pauseButton);
var stop = FindViewById<Button>(Resource.Id.stopButton);
seekBar = FindViewById<SeekBar>(Resource.Id.seekBar1);
status = FindViewById<TextView>(Resource.Id.statusText);
updateHandler = new Handler();
player = new MediaPlayer();
player.SetDataSource(this, Android.Net.Uri.Parse(episode.AudioUrl));
player.PrepareAsync();
player.Prepared += (sender, e) =>
{
initialized = true;
player.SeekTo(timeToSet * 1000);
UpdateStatus();
};
play.Click += (sender, e) =>
{
player.Start();
updateHandler.PostDelayed(UpdateStatus, 1000);
};
pause.Click += (sender, e) => player.Pause();
stop.Click += (sender, e) =>
{
player.Stop();
player.Reset();
player.SetDataSource(this, Android.Net.Uri.Parse(episode.AudioUrl));
player.Prepare();
};
seekBar.ProgressChanged += (sender, e) =>
{
if (!e.FromUser)
return;
player.SeekTo((int)(player.Duration * ((float)seekBar.Progress / 100.0)));
};
var updated = await episode.GetTimeAsync();
if (updated == null || updated.ShowNumber != episode.ShowNumber)
return;
if (initialized && player != null)
{
player.SeekTo(updated.CurrentTime * 1000);
UpdateStatus();
}
else
{
timeToSet = updated.CurrentTime;
}
}
示例5: OnCompletion
public void OnCompletion(MediaPlayer mp)
{
mp.SeekTo (0);
mp.Pause ();
}