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


C# BackgroundAudioPlayer.Close方法代码示例

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


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

示例1: OnPlayStateChanged

        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            switch (playState)
            {
                case PlayState.TrackEnded:
                    player.Close();
                    break;

                case PlayState.TrackReady:
                    player.Volume = 1.0;
                    player.Play();
                    break;

                case PlayState.Shutdown:
                    // TODO: Handle the shutdown state here (e.g. save state)
                    break;

                case PlayState.Unknown:
                    break;

                case PlayState.Stopped:
                    break;

                case PlayState.Paused:
                    break;

                case PlayState.Playing:
                    break;

                case PlayState.BufferingStarted:
                    break;

                case PlayState.BufferingStopped:
                    break;

                case PlayState.Rewinding:
                    break;

                case PlayState.FastForwarding:
                    break;
            }

            NotifyComplete();
        }
开发者ID:juhariis,项目名称:Windows-Phone-Starter-Kit-for-Podcasts,代码行数:44,代码来源:AudioPlayer.cs

示例2: OnUserAction

        /// <summary>
        ///     Called when the user requests an action using application/system provided UI
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time of the user action</param>
        /// <param name="action">The action the user has requested</param>
        /// <param name="param">
        ///     The data associated with the requested action.
        ///     In the current version this parameter is only for use with the Seek action,
        ///     to indicate the requested position of an audio track
        /// </param>
        /// <remarks>
        ///     User actions do not automatically make any changes in system state; the agent is responsible
        ///     for carrying out the user actions if they are supported.
        ///     Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnUserAction(BackgroundAudioPlayer player, AudioTrack track, UserAction action, object param)
        {
            Debug.WriteLine("AudioPlayer.OnUserAction() track.Source {0} track.Tag {1} action {2}",
                null == track ? "<no track>" : null == track.Source ? "<none>" : track.Source.ToString(),
                null == track ? "<no track>" : track.Tag ?? "<none>", action);

            try
            {
                switch (action)
                {
                    case UserAction.Play:
                        UpdateTrack(player);

                        if (PlayState.Playing != player.PlayerState && null != player.Track)
                            player.Play();

                        break;
                    case UserAction.Stop:
                        player.Stop();

                        break;
                    case UserAction.Pause:
                        if (PlayState.Playing == player.PlayerState)
                            player.Pause();

                        break;
                    case UserAction.FastForward:
                        if (null != track && null != track.Source)
                            player.FastForward();

                        break;
                    case UserAction.Rewind:
                        if (null != track && null != track.Source)
                            player.Rewind();

                        break;
                    case UserAction.Seek:
                        if (null != track)
                            player.Position = (TimeSpan)param;

                        break;
                    case UserAction.SkipNext:
                        player.Track = GetNextTrack();

                        if (PlayState.Playing != player.PlayerState && null != player.Track)
                            player.Play();

                        break;
                    case UserAction.SkipPrevious:
                        var previousTrack = GetPreviousTrack();
                        if (previousTrack != null)
                            player.Track = previousTrack;

                        if (PlayState.Playing != player.PlayerState && null != player.Track)
                            player.Play();

                        break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("AudioPlayer.OnUserAction() failed: " + ex.ExtendedMessage());

                // Is there anything we can do about this?
                try
                {
                    player.Close();
                }
                catch (Exception ex2)
                {
                    Debug.WriteLine("AudioPlayer.OnUserAction() close failed: " + ex2.ExtendedMessage());
                }
            }
            finally
            {
                NotifyComplete();
            }
        }
开发者ID:henricj,项目名称:phonesm,代码行数:94,代码来源:AudioPlayer.cs

示例3: OnPlayStateChanged

        /// <summary>
        /// Called when the playstate changes, except for the Error state (see OnError)
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time the playstate changed</param>
        /// <param name="playState">The new playstate of the player</param>
        /// <remarks>
        /// Play State changes cannot be cancelled. They are raised even if the application
        /// caused the state change itself, assuming the application has opted-in to the callback.
        /// 
        /// Notable playstate events: 
        /// (a) TrackEnded: invoked when the player has no current track. The agent can set the next track.
        /// (b) TrackReady: an audio track has been set and it is now ready for playack.
        /// 
        /// Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            switch (playState)
            {
                case PlayState.TrackEnded:
                    if (currentPlaylist.Count > 0)
                        player.Track = GetNextTrack();
                    break;
                case PlayState.TrackReady:
                    track.BeginEdit();
                    track.Title = currentPlaylist[currentTrackNumber].Title;
                    track.EndEdit();
                    player.Play();
                    break;
                case PlayState.Shutdown:
                    // TODO: Handle the shutdown state here (e.g. save state)
                    player.Close();
                    break;
                case PlayState.Unknown:
                    break;
                case PlayState.Stopped:
                    break;
                case PlayState.Paused:
                    break;
                case PlayState.Playing:
                    break;
                case PlayState.BufferingStarted:
                    track.BeginEdit();
                        track.Title = "Buffering...";
                    track.EndEdit();
                    break;
                case PlayState.BufferingStopped:
                    track.BeginEdit();
                    track.Title = currentPlaylist[currentTrackNumber].Title;
                    track.EndEdit();
                    break;
                case PlayState.Rewinding:
                    track.BeginEdit();
                    track.Title = "Rewinding...";
                    track.EndEdit();
                    break;
                case PlayState.FastForwarding:
                    track.BeginEdit();
                    track.Title = "FastForwarding...";
                    track.EndEdit();
                    break;
            }

            NotifyComplete();
        }
开发者ID:ahmeda8,项目名称:audio-youtube-wp7,代码行数:66,代码来源:AudioPlayer.cs


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