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


C# MediaPlayer.SeekTo方法代码示例

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


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

示例1: OnElementChanged

        protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
        {
            base.OnElementChanged(e);
            if (Element == null)
                return;

            player = new MediaPlayer();
            timer = new Timer(1000);
            timer.Elapsed += timer_Elapsed;

            player.Prepared += (sender, args) =>
              {
                  try
                  {
                      player.SeekTo(0);
                      player.Start();
                      timer.Start();
                  }
                  catch
                  {
                  }
              };

            if (string.IsNullOrWhiteSpace(Player.Url))
                return;

            InitPlayer();

        }
开发者ID:Adam--,项目名称:Hanselman.Forms,代码行数:29,代码来源:AudioPlayerRenderer.cs

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

示例3: OnStart

        /// <summary>
        /// Ons the start.
        /// </summary>
        /// <param name='intent'> Intent.</param>
        /// <param name='startId'>Start identifier.</param>
        public override void OnStart(Intent intent, int startId)
        {
            base.OnStart(intent, startId);
              stop();

              episode = EpisodeList.SelectedEpisode;
              player = MediaPlayer.Create(PortaPodderApp.Context, Android.Net.Uri.Parse(PortaPodderDataSource.GetEpisodeLocation(episode)));

              // set the player to update the episode current position whenever a seek operation is sent
              player.SeekComplete += delegate(object sender, EventArgs e) {
            episode.PlayerPosition = player.CurrentPosition;
              };

              // there is not duration meta-data to be had in the gpodder data structures, so we need to determine it once the media player has
              // been created and set it at this time and then broadcast it
              episode.Duration = player.Duration;

              // go to the last recorded position and start playing from there
              player.SeekTo(episode.PlayerPosition);
              player.Start();

              // the progress monitor is the background thread which is going to send broadcasts about how far along the player is
              progressMonitor.Stop = false;
              if(!progressMonitor.IsRunning) {
            progressMonitor.Execute();
              }

              // now bind an incoming message reciever for operations
              IntentFilter intentToReceiveFilter = new IntentFilter();
              intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_RELATIVE_FORWARD);
              intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_RELATIVE_BACKWARD);
              intentToReceiveFilter.AddAction(PLAYER_INSTRUCTION_SEEK_ABSOLUTE);
              this.RegisterReceiver(reciever, intentToReceiveFilter, null, handler);
              receiversRegistered = true;
        }
开发者ID:brianbourke75,项目名称:PortaPodder,代码行数:40,代码来源:EpisodePlayer.cs

示例4: OnPrepared

                public void OnPrepared( MediaPlayer mp )
                {
                    // now that the video is ready we can hide the progress bar
                    ProgressBar.Visibility = ViewStates.Gone;

                    MediaController.SetAnchorView( VideoPlayer );

                    // setup a seek listener
                    mp.SetOnSeekCompleteListener( this );

                    // log the series they tapped on.
                    MessageAnalytic.Instance.Trigger( MessageAnalytic.Watch, Name );

                    // if this is a new video, store the URL
                    if ( App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl != MediaUrl )
                    {
                        App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl = MediaUrl;
                        VideoPlayer.Start( );

                        // once the video starts, if we're in landscape wide, go full screen
                        if ( MainActivity.IsLandscapeWide( ) )
                        {
                            ParentTask.NavbarFragment.ToggleFullscreen( true );
                        }
                    }
                    else
                    {
                        // otherwise, resume where we left off
                        mp.SeekTo( (int)App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaPos );
                    }
                }
开发者ID:Higherbound,项目名称:HBMobileApp,代码行数:31,代码来源:NotesWatchFragment.cs

示例5: OnPrepared

                public void OnPrepared( MediaPlayer mp )
                {
                    Rock.Mobile.Util.Debug.WriteLine( "OnPrepared - Audio ready to play" );

                    // now that we know the media player is read, set the controller's player
                    MediaController.SetMediaPlayer( this );
                    MediaControllerPrepared = true;

                    // setup a seek listener
                    mp.SetOnSeekCompleteListener( this );

                    // log the series they tapped on.
                    MessageAnalytic.Instance.Trigger( MessageAnalytic.Listen, Name );

                    // if this is a new video, store the URL
                    if ( App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl != MediaUrl )
                    {
                        App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl = MediaUrl;

                        PlayerState = MediaPlayerState.Playing;
                        mp.Start( );

                        SyncUI( );
                    }
                    else
                    {
                        // otherwise, resume where we left off
                        mp.SeekTo( (int)App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaPos );
                    }
                }
开发者ID:Higherbound,项目名称:HBMobileApp,代码行数:30,代码来源:NotesListenFragment.cs

示例6: OnCompletion

 public void OnCompletion(MediaPlayer mp)
 {
     mp.SeekTo (0);
     mp.Pause ();
 }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:5,代码来源:AboutShowTutorialFragment.cs

示例7: OnCompletion

 public void OnCompletion(MediaPlayer mediaPlayer)
 {
     mediaPlayer.SeekTo(0);
 }
开发者ID:ebeisecker,项目名称:Playpen,代码行数:4,代码来源:BarcodeScanActivity.cs


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