當前位置: 首頁>>代碼示例>>C#>>正文


C# BackgroundAudioPlayer.SafeGetPlayerState方法代碼示例

本文整理匯總了C#中BackgroundAudioPlayer.SafeGetPlayerState方法的典型用法代碼示例。如果您正苦於以下問題:C# BackgroundAudioPlayer.SafeGetPlayerState方法的具體用法?C# BackgroundAudioPlayer.SafeGetPlayerState怎麽用?C# BackgroundAudioPlayer.SafeGetPlayerState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BackgroundAudioPlayer的用法示例。


在下文中一共展示了BackgroundAudioPlayer.SafeGetPlayerState方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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)
        {
            switch (action)
            {
                case UserAction.Play:
                    if (track != null && track.Tag != null)
                    {
                        var data = track.Tag.ToString().Split('$');
                        var url = data[data.Length - 1];

                        var type = data[2];

                        if (type.ToLower() != "shoutcast")
                        {
                            track.Source = new Uri(url);
                        }
                    }

                    //player.Track = new AudioTrack(null, "", "", "", null, track.Tag, EnabledPlayerControls.Pause);
                    if (player.SafeGetPlayerState() != PlayState.Playing)
                    {
                        player.Play();
                    }
                    break;
                case UserAction.Stop:
                    if (player.SafeGetPlayerState() == PlayState.Playing)
                        player.Stop();
                    break;
                case UserAction.Pause:
                    if (player.SafeGetPlayerState() == PlayState.Playing)
                        player.Pause();
                    break;
                case UserAction.FastForward:
                    //player.FastForward();
                    break;
                case UserAction.Rewind:
                    //player.Rewind();
                    break;
                case UserAction.Seek:
                    //player.Position = (TimeSpan)param;
                    break;
                case UserAction.SkipNext:
                    //player.Track = GetNextTrack();
                    break;
                case UserAction.SkipPrevious:
                    //AudioTrack previousTrack = GetPreviousTrack();
                    //if (previousTrack != null)
                    //{
                    //    player.Track = previousTrack;
                    //}
                    break;
            }

            NotifyComplete();
        }
開發者ID:Amrykid,項目名稱:Hanasu,代碼行數:70,代碼來源:AudioPlayer.cs


注:本文中的BackgroundAudioPlayer.SafeGetPlayerState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。