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


C# MediaPlayer.Stop方法代码示例

本文整理汇总了C#中Android.Media.MediaPlayer.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Stop方法的具体用法?C# MediaPlayer.Stop怎么用?C# MediaPlayer.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Media.MediaPlayer的用法示例。


在下文中一共展示了MediaPlayer.Stop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: Play

 public void Play(int resId)
 {
     try
     {
         if (player != null)
         {
             //if (player.IsPlaying)
             //{
             //    player.Stop();
             //    player.Reset();
             //}
             player.Reset();
         }
         player = MediaPlayer.Create(Application.Context, resid: resId);
         player.Stop();
         player.Prepare();
         player.Start();
     }
     catch (Exception ex)
     {
         System.Console.Out.WriteLine(ex.StackTrace);
     }
 }
开发者ID:shawancyb,项目名称:VoiceTimeCounter,代码行数:23,代码来源:AudioPlayer.cs

示例4: OnStop

 public void OnStop(MediaPlayer player)
 {
     player.Stop();
 }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:4,代码来源:AudioManager.cs

示例5: OnCompletion

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

示例6: 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;
      }
    }
开发者ID:rampyodm,项目名称:XamarinDNR,代码行数:70,代码来源:PodcastDetailActivity.cs

示例7: 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

示例8: OnCreate

                public override void OnCreate()
                {
                    base.OnCreate();

                    Rock.Mobile.Util.Debug.WriteLine( "AudioService::OnCreate" );

                    Binder = new AudioServiceBinder( this );

                    // prepare our media player
                    MediaPlayer = new MediaPlayer();
                    MediaPlayer.SetAudioStreamType( Stream.Music );
                    MediaPlayer.Stop( );
                }
开发者ID:Higherbound,项目名称:HBMobileApp,代码行数:13,代码来源:NotesListenFragment.cs

示例9: 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;
                }
开发者ID:Higherbound,项目名称:HBMobileApp,代码行数:29,代码来源:NotesListenFragment.cs


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