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


C# MediaPlayer.Release方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:jorik041,项目名称:Sample-Projects,代码行数:35,代码来源:CustomWebChromeClient.cs

示例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 ();
			}
		}
开发者ID:instantiator,项目名称:BAASBox.SampleApp,代码行数:32,代码来源:LocalAdaptor.cs

示例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;
        }
开发者ID:bronsonmcn,项目名称:AoESoundBoard,代码行数:11,代码来源:PlayAudio_Android.cs

示例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;
 }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:12,代码来源:AudioManager.cs

示例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;
 }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:12,代码来源:videoPlay.cs

示例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
     }
 }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:14,代码来源:AudioManager.cs

示例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);
			}
		}
开发者ID:jcapuano328,项目名称:LB.mono,代码行数:14,代码来源:PlayAudio.cs

示例8: OnCompletion

 public void OnCompletion(MediaPlayer p)
 {
     p.Stop ();
     p.Release ();
 }
开发者ID:sonalpathak,项目名称:MySecurity,代码行数:5,代码来源:trial.cs

示例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;
        }
开发者ID:sonalpathak,项目名称:MySecurity,代码行数:22,代码来源:alarm.cs


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