本文整理汇总了C#中Android.Media.MediaPlayer.Release方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Release方法的具体用法?C# MediaPlayer.Release怎么用?C# MediaPlayer.Release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.Release方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnProgressChanged
public override void OnProgressChanged(WebView view, int newProgress)
{
base.OnProgressChanged(view, newProgress);
_context.SetProgress(newProgress * 100);
if (newProgress == 100)
{
_context.Title = view.Title;
bool soundEnabled = PreferenceManager.GetDefaultSharedPreferences(_context.ApplicationContext).GetBoolean("sounds", false);
if (soundEnabled)
{
_mediaPlayer = MediaPlayer.Create(_context.ApplicationContext, Resource.Raw.inception_horn);
_mediaPlayer.Completion += delegate { _mediaPlayer.Release(); };
_mediaPlayer.Start();
}
// add this page to the history
using (SQLiteDatabase db = _historyDataHelper.WritableDatabase)
{
var values = new ContentValues();
values.Put("Title", view.Title);
values.Put("Url", view.Url);
values.Put("Timestamp", DateTime.Now.Ticks);
db.Insert("history", null, values);
}
}
else
{
_context.Title = _context.ApplicationContext.Resources.GetString(Resource.String.title_loading);
}
}
示例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: Play
public bool Play()
{
_player = MediaPlayer.Create(global::Android.App.Application.Context, Resource.Raw._01yes);
_player.Start();
_player.Completion += delegate
{
_player.Release();
};
return true;
}
示例4: 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;
}
示例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: 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);
}
}
示例8: OnCompletion
public void OnCompletion(MediaPlayer p)
{
p.Stop ();
p.Release ();
}
示例9: 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;
}