本文整理汇总了C#中Android.Media.MediaPlayer.SetOnErrorListener方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.SetOnErrorListener方法的具体用法?C# MediaPlayer.SetOnErrorListener怎么用?C# MediaPlayer.SetOnErrorListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Media.MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.SetOnErrorListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.video);
url = base.Intent.GetStringExtra("url");
int x = base.Intent.GetIntExtra("xSize", 300);
int y = base.Intent.GetIntExtra("ySize", 500);
string urlHost = "http://replays.robertsstream.com/racereplays/replaysmobile.php?";
//urlHost = "rtsp://66.209.93.10:554/2012/_definst_/300/mp4:" + url + "_300.mp4?";
string pk = "oq56rfju4vnjkm789grt";
DateTime d1 = new DateTime(1970, 1, 1);
DateTime d2 = DateTime.UtcNow;
TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
double sd = ts.TotalMilliseconds;
string UTC = sd.ToString().Substring(0, 10);
string MD5String = UTC + pk + url;
MD5String = GetMD5Hash(MD5String);
urlHost += "race=" + url;
urlHost += "&cust=OQHRA";
urlHost += "&t=" + UTC;
urlHost += "&h=" + MD5String;
url = resolveRedirect(urlHost);
if (url == "cant")
return;
if (mp != null)
{
mp.Reset();
mp.Release();
}
mp = new Android.Media.MediaPlayer();
mp.SetOnErrorListener(this);
var surface = FindViewById<SurfaceView>(Resource.Id.surfaceView);
var holder = surface.Holder;
#if DEBUG
Console.WriteLine("surface.Holder = {0}", surface.Holder);
#endif
holder.AddCallback(this);
holder.SetType(Android.Views.SurfaceType.PushBuffers);
holder.SetFixedSize(x - 50, y - 75);
#if DEBUG
Console.WriteLine("videoplayer - url = {0}, x - 50 = {1}, y - 75 = {2}, mp.Info = {3}", url, x - 50, y - 75, mp);
#endif
Button btnClose = FindViewById<Button>(Resource.Id.btnClose);
btnClose.Click += (object s, EventArgs e) => { this.Finish(); };
}
示例2: CreateMediaPlayerIfNeeded
void CreateMediaPlayerIfNeeded ()
{
LogHelper.Debug (Tag, "createMediaPlayerIfNeeded. needed? ", (mediaPlayer==null));
if (mediaPlayer == null) {
mediaPlayer = new MediaPlayer ();
mediaPlayer.SetWakeMode (service.ApplicationContext,
Android.OS.WakeLockFlags.Partial);
mediaPlayer.SetOnPreparedListener (this);
mediaPlayer.SetOnCompletionListener (this);
mediaPlayer.SetOnErrorListener (this);
mediaPlayer.SetOnSeekCompleteListener (this);
} else {
mediaPlayer.Reset ();
}
}
示例3: InitMusicPlayer
public void InitMusicPlayer()
{
_appSettingsHelper = new AppSettingsHelper();
_player = new MediaPlayer();
_wifiLock = ((WifiManager)GetSystemService(WifiService)).CreateWifiLock(WifiMode.Full, "playerLock");
_player.SetWakeMode(ApplicationContext, WakeLockFlags.Partial);
_player.SetAudioStreamType(Stream.Music);
_player.SetOnPreparedListener(this);
_player.SetOnCompletionListener(this);
_player.SetOnErrorListener(this);
_audioManager = (AudioManager) GetSystemService(AudioService);
_mediaButtonReceiverComponent = new ComponentName(ApplicationContext,
Class.FromType(typeof (HeadsetButtonsReceiver)));
_audioManager.RegisterMediaButtonEventReceiver(_mediaButtonReceiverComponent);
}
示例4: InitializePlayer
/// <summary>
/// Intializes the player.
/// </summary>
private void InitializePlayer ()
{
mediaPlayer = new MediaPlayer ();
//Tell our player to sream music
mediaPlayer.SetAudioStreamType (Stream.Music);
//Wake mode will be partial to keep the CPU still running under lock screen
mediaPlayer.SetWakeMode (ApplicationContext, WakeLockFlags.Partial);
mediaPlayer.SetOnBufferingUpdateListener (this);
mediaPlayer.SetOnCompletionListener (this);
mediaPlayer.SetOnErrorListener (this);
mediaPlayer.SetOnPreparedListener (this);
}