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


C# MediaPlayer.Reset方法代码示例

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


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

示例1: StartPlayer

        public void StartPlayer(AssetFileDescriptor filePath)
        {
            if (player == null)
            {
                player = new MediaPlayer();
                player.Reset();
                /*

                player.SetDataSource(filePath.FileDescriptor, filePath.StartOffset, filePath.Length);
                player.Prepare();
                player.Start();
                 * */

            }
            if(player != null)
            {
                //player.Reset();
                player.SetDataSource(filePath.FileDescriptor, filePath.StartOffset, filePath.Length);
                player.Prepare();
                if (AudioPosition > 0)
                {
                   player.SeekTo(AudioPosition);
                }
                player.Start();
            }
        }
开发者ID:ConundrumSystems,项目名称:PowerpointAppStyle,代码行数:26,代码来源:AudioPlayer.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: 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

示例4: OnResume

        protected override void OnResume()
        {
            base.OnResume ();

            _recorder = new MediaRecorder ();
            _player = new MediaPlayer ();

            _player.Completion += (sender, e) => {
                _player.Reset ();
                _start.Enabled = !_start.Enabled;
            };
        }
开发者ID:yofanana,项目名称:recipes,代码行数:12,代码来源:Activity1.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: Resume

        public void Resume()
        {
            //base.OnResume();

            _recorder = new MediaRecorder();
            _player = new MediaPlayer();

            _player.Completion += (sender, e) =>
            {
                _player.Reset();

                MessagingCenter.Send<ISoundRecorder>(this, "MediaPlayer.Complete");
            };
        }
开发者ID:kunzuzz,项目名称:SoundRecorder,代码行数:14,代码来源:SoundRecorder.cs

示例8: OnResume

        protected override void OnResume()
        {
            base.OnResume();

            _recorder = new MediaRecorder();
            _player = new MediaPlayer();

            _player.Completion += (sender, e) =>
            {
                _player.Reset();
                _btnRecord.Enabled = true;
                _btnPlay.Enabled = true;
            };
        }
开发者ID:DominikMe,项目名称:zpeek,代码行数:14,代码来源:MainActivity.cs

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

示例10: OnResume

        protected override void OnResume()
        {
            base.OnResume ();
            _recorder = new MediaRecorder ();
            _player = new MediaPlayer ();

            _player.Completion += (sender, e) => {
                _player.Reset ();

            };

            _photoAdapter.NotifyDataSetChanged ();
            _recordAdapter.NotifyDataSetChanged ();
        }
开发者ID:WenF,项目名称:SSCA_FlagThis,代码行数:14,代码来源:MessageActivity.cs

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