本文整理汇总了C#中Android.Media.MediaPlayer.SeekTo方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.SeekTo方法的具体用法?C# MediaPlayer.SeekTo怎么用?C# MediaPlayer.SeekTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.SeekTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
{
base.OnElementChanged(e);
if (Element == null)
return;
player = new MediaPlayer();
timer = new Timer(1000);
timer.Elapsed += timer_Elapsed;
player.Prepared += (sender, args) =>
{
try
{
player.SeekTo(0);
player.Start();
timer.Start();
}
catch
{
}
};
if (string.IsNullOrWhiteSpace(Player.Url))
return;
InitPlayer();
}
示例2: 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;
}
}
示例3: OnStart
/// <summary>
/// Ons the start.
/// </summary>
/// <param name='intent'> Intent.</param>
/// <param name='startId'>Start identifier.</param>
public override void OnStart(Intent intent, int startId)
{
base.OnStart(intent, startId);
stop();
episode = EpisodeList.SelectedEpisode;
player = MediaPlayer.Create(PortaPodderApp.Context, Android.Net.Uri.Parse(PortaPodderDataSource.GetEpisodeLocation(episode)));
// set the player to update the episode current position whenever a seek operation is sent
player.SeekComplete += delegate(object sender, EventArgs e) {
episode.PlayerPosition = player.CurrentPosition;
};
// there is not duration meta-data to be had in the gpodder data structures, so we need to determine it once the media player has
// been created and set it at this time and then broadcast it
episode.Duration = player.Duration;
// go to the last recorded position and start playing from there
player.SeekTo(episode.PlayerPosition);
player.Start();
// the progress monitor is the background thread which is going to send broadcasts about how far along the player is
progressMonitor.Stop = false;
if(!progressMonitor.IsRunning) {
progressMonitor.Execute();
}
// now bind an incoming message reciever for operations
IntentFilter intentToReceiveFilter = new IntentFilter();
intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_RELATIVE_FORWARD);
intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_RELATIVE_BACKWARD);
intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_ABSOLUTE);
this.RegisterReceiver(reciever, intentToReceiveFilter, null, handler);
receiversRegistered = true;
}
示例4: OnPrepared
public void OnPrepared( MediaPlayer mp )
{
// now that the video is ready we can hide the progress bar
ProgressBar.Visibility = ViewStates.Gone;
MediaController.SetAnchorView( VideoPlayer );
// setup a seek listener
mp.SetOnSeekCompleteListener( this );
// log the series they tapped on.
MessageAnalytic.Instance.Trigger( MessageAnalytic.Watch, Name );
// if this is a new video, store the URL
if ( App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl != MediaUrl )
{
App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl = MediaUrl;
VideoPlayer.Start( );
// once the video starts, if we're in landscape wide, go full screen
if ( MainActivity.IsLandscapeWide( ) )
{
ParentTask.NavbarFragment.ToggleFullscreen( true );
}
}
else
{
// otherwise, resume where we left off
mp.SeekTo( (int)App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaPos );
}
}
示例5: OnPrepared
public void OnPrepared( MediaPlayer mp )
{
Rock.Mobile.Util.Debug.WriteLine( "OnPrepared - Audio ready to play" );
// now that we know the media player is read, set the controller's player
MediaController.SetMediaPlayer( this );
MediaControllerPrepared = true;
// setup a seek listener
mp.SetOnSeekCompleteListener( this );
// log the series they tapped on.
MessageAnalytic.Instance.Trigger( MessageAnalytic.Listen, Name );
// if this is a new video, store the URL
if ( App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl != MediaUrl )
{
App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl = MediaUrl;
PlayerState = MediaPlayerState.Playing;
mp.Start( );
SyncUI( );
}
else
{
// otherwise, resume where we left off
mp.SeekTo( (int)App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaPos );
}
}
示例6: OnCompletion
public void OnCompletion(MediaPlayer mp)
{
mp.SeekTo (0);
mp.Pause ();
}
示例7: OnCompletion
public void OnCompletion(MediaPlayer mediaPlayer)
{
mediaPlayer.SeekTo(0);
}