当前位置: 首页>>代码示例>>C#>>正文


C# MediaPlayer.SetOnErrorListener方法代码示例

本文整理汇总了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(); };
        }
开发者ID:nodoid,项目名称:Webview,代码行数:52,代码来源:videoplayer.cs

示例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 ();
			}
		}
开发者ID:Appercode,项目名称:monodroid-samples,代码行数:17,代码来源:Playback.cs

示例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);
        }
开发者ID:jayharry28,项目名称:Audiotica,代码行数:18,代码来源:AudioPlaybackService.cs

示例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);
        }
开发者ID:helmsb,项目名称:AndroidStreamingAudio,代码行数:18,代码来源:MediaPlayerService.cs


注:本文中的Android.Media.MediaPlayer.SetOnErrorListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。