本文整理汇总了C#中Android.Media.MediaPlayer.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Reset方法的具体用法?C# MediaPlayer.Reset怎么用?C# MediaPlayer.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.Reset方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartPlayer
public void StartPlayer(AssetFileDescriptor filePath)
{
if (player == null)
{
player = new MediaPlayer();
player.Reset();
/*
player.SetDataSource(filePath.FileDescriptor, filePath.StartOffset, filePath.Length);
player.Prepare();
player.Start();
* */
}
if(player != null)
{
//player.Reset();
player.SetDataSource(filePath.FileDescriptor, filePath.StartOffset, filePath.Length);
player.Prepare();
if (AudioPosition > 0)
{
player.SeekTo(AudioPosition);
}
player.Start();
}
}
示例2: InitAndPlayAudio
public void InitAndPlayAudio (string trackSource)
{
var resourceId = GetRawResourceId(trackSource);
Console.WriteLine("Resource id for " + trackSource + " = "
+ (resourceId.HasValue ? resourceId.Value.ToString() : "(null)"));
if (player != null) {
if (player.IsPlaying) {
player.Stop ();
}
player.Reset ();
player.Release ();
player = null;
}
if (resourceId.HasValue) {
player = MediaPlayer.Create (Application.Context, resourceId.Value);
// do not use player.Prepare () -- MediaPlayer.Create takes care of this
player.Completion += (sender, e) => {
player.Reset ();
player.Release ();
player = null;
AudioState = AudioState.Stopped;
};
AudioState = AudioState.Playing;
player.Start ();
}
}
示例3: findDuration
public int findDuration(string filename)
{
MediaPlayer wav = new MediaPlayer();
FileInputStream fs = new FileInputStream(filename);
FileDescriptor fd = fs.FD;
wav.SetDataSource(fd);
wav.Prepare();
int length = wav.Duration;
wav.Reset();
wav.Release();
return length;
}
示例4: OnResume
protected override void OnResume()
{
base.OnResume ();
_recorder = new MediaRecorder ();
_player = new MediaPlayer ();
_player.Completion += (sender, e) => {
_player.Reset ();
_start.Enabled = !_start.Enabled;
};
}
示例5: videoDuration
public int videoDuration(string filename)
{
MediaPlayer video = new MediaPlayer();
FileInputStream fs = new FileInputStream(filename);
FileDescriptor fd = fs.FD;
video.SetDataSource(fd);
video.Prepare();
int length = video.Duration;
video.Reset();
video.Release();
return length;
}
示例6: 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
}
}
示例7: Resume
public void Resume()
{
//base.OnResume();
_recorder = new MediaRecorder();
_player = new MediaPlayer();
_player.Completion += (sender, e) =>
{
_player.Reset();
MessagingCenter.Send<ISoundRecorder>(this, "MediaPlayer.Complete");
};
}
示例8: OnResume
protected override void OnResume()
{
base.OnResume();
_recorder = new MediaRecorder();
_player = new MediaPlayer();
_player.Completion += (sender, e) =>
{
_player.Reset();
_btnRecord.Enabled = true;
_btnPlay.Enabled = true;
};
}
示例9: 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;
}
}
示例10: OnResume
protected override void OnResume()
{
base.OnResume ();
_recorder = new MediaRecorder ();
_player = new MediaPlayer ();
_player.Completion += (sender, e) => {
_player.Reset ();
};
_photoAdapter.NotifyDataSetChanged ();
_recordAdapter.NotifyDataSetChanged ();
}
示例11: 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;
}