本文整理汇总了C#中Android.Media.MediaPlayer.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Stop方法的具体用法?C# MediaPlayer.Stop怎么用?C# MediaPlayer.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.Stop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCompletion
public void OnCompletion(MediaPlayer player)
{
try
{
player.Stop();
player.Reset();
player.Release();
} catch (Exception ex)
{
#if DEBUG
System.Diagnostics.Debug.WriteLine("Exception in audio {0}", ex.Message);
#endif
}
}
示例2: Play
public void Play ()
{
try {
player = MediaPlayer.Create (context, Resource.Raw.droll);
player.Completion += (object sender, EventArgs e) => {
player.Stop ();
player.Release ();
player = null;
};
player.Start ();
} catch (Exception ex) {
Console.Out.WriteLine (ex.StackTrace);
}
}
示例3: Play
public void Play(int resId)
{
try
{
if (player != null)
{
//if (player.IsPlaying)
//{
// player.Stop();
// player.Reset();
//}
player.Reset();
}
player = MediaPlayer.Create(Application.Context, resid: resId);
player.Stop();
player.Prepare();
player.Start();
}
catch (Exception ex)
{
System.Console.Out.WriteLine(ex.StackTrace);
}
}
示例4: OnStop
public void OnStop(MediaPlayer player)
{
player.Stop();
}
示例5: OnCompletion
public void OnCompletion(MediaPlayer p)
{
p.Stop ();
p.Release ();
}
示例6: 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;
}
}
示例7: OnCreate
protected override void OnCreate(Bundle bundle)
{
_player = MediaPlayer.Create (this,Resource.Raw.police_alarm);
base.OnCreate (bundle);
SetContentView (Resource.Layout.alarm);
ImageButton start = FindViewById<ImageButton> (Resource.Id.Start_ALarm);
start.Click += delegate {
_player = MediaPlayer.Create (this,Resource.Raw.police_alarm);
_player.Start ();
};
ImageButton stop = FindViewById<ImageButton> (Resource.Id.Stop_ALarm);
stop.Click += delegate {
_player.Stop ();
_player.Release();
_player=null;
// Intent i = new Intent (this, typeof(MainActivity));
// StartActivity (i);
};
// FindViewById<TextView> (Resource.Id.Start_ALarm).Click+=Start_alarm_click;
//FindViewById<TextView> (Resource.Id.Stop_ALarm).Click += Stop_alarm_click;
}
示例8: OnCreate
public override void OnCreate()
{
base.OnCreate();
Rock.Mobile.Util.Debug.WriteLine( "AudioService::OnCreate" );
Binder = new AudioServiceBinder( this );
// prepare our media player
MediaPlayer = new MediaPlayer();
MediaPlayer.SetAudioStreamType( Stream.Music );
MediaPlayer.Stop( );
}
示例9: OnError
public bool OnError( MediaPlayer mp, MediaError error, int extra )
{
ProgressBar.Visibility = ViewStates.Gone;
// only show the resultView if we're active.
if( FragmentActive == true )
{
ResultView.Show( MessagesStrings.Error_Title,
PrivateControlStylingConfig.Result_Symbol_Failed,
MessagesStrings.Error_Watch_Playback,
GeneralStrings.Retry );
ResultView.SetBounds( new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ) );
}
if( mp != null )
{
mp.Stop( );
mp.Reset( );
}
MediaControllerPrepared = false;
PlayerState = MediaPlayerState.None;
//SyncUI( );
return true;
}