コード例 #1
0
        private async Task ConfigureThePlayer()
        {
            var tcs = new TaskCompletionSource <bool>();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                WPLogger.AppVersion = ApplicationManifest.Current.App.Version;
                WPLogger.LogConfiguration.LogType          = LogType.WriteToFile;
                WPLogger.LogConfiguration.LoggingIsEnabled = true;

                if (ApplicationSettings == null)
                {
                    ApplicationSettings = new ApplicationSettingsService().Legacy;
                }

                if (_logger == null)
                {
                    _logger = new WPLogger(GetType());
                }

                if (_playlistHelper == null)
                {
                    _playlistHelper = new PlaylistHelper(new StorageService());
                }

                if (_apiClient == null)
                {
                    CreateClient();
                }

                tcs.SetResult(true);
            });

            await tcs.Task;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the PlaylistViewModel class.
        /// </summary>
        public NowPlayingViewModel(INavigationService navigationService, IConnectionManager connectionManager, IStorageService storageService)
            :base (navigationService, connectionManager)
        {
            _playlistChecker = new DispatcherTimer { Interval = new TimeSpan(0, 0, 3) };
            _playlistChecker.Tick += PlaylistCheckerOnTick;

            Playlist = new ObservableCollection<PlaylistItem>();
            SelectedItems = new List<PlaylistItem>();
            if (IsInDesignMode)
            {
                Playlist = new ObservableCollection<PlaylistItem>
                {
                    new PlaylistItem {Artist = "John Williams", Album = "Jurassic Park OST", Id = 1, IsPlaying = true, TrackName = "Jurassic Park Theme"},
                    new PlaylistItem {Artist = "John Williams", Album = "Jurassic Park OST", Id = 2, IsPlaying = false, TrackName = "Journey to the Island"},
                    new PlaylistItem {Artist = "John Williams", Album = "Jurassic Park OST", Id = 10, IsPlaying = false, TrackName = "Incident at Isla Nublar"}
                };
                NowPlayingItem = Playlist[0];
            }
            else
            {
                _playlistHelper = new PlaylistHelper(storageService);
                BackgroundAudioPlayer.Instance.PlayStateChanged += OnPlayStateChanged;
                GetPlaylistItems();
                IsPlaying = BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing;
            }
        }
コード例 #3
0
        private async Task ConfigureThePlayer()
        {
            var tcs = new TaskCompletionSource<bool>();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                WPLogger.AppVersion = ApplicationManifest.Current.App.Version;
                WPLogger.LogConfiguration.LogType = LogType.WriteToFile;
                WPLogger.LogConfiguration.LoggingIsEnabled = true;

                if (ApplicationSettings == null)
                {
                    ApplicationSettings = new ApplicationSettingsService().Legacy;
                }

                if (_logger == null)
                {
                    _logger = new WPLogger(GetType());
                }

                if (_playlistHelper == null)
                {
                    _playlistHelper = new PlaylistHelper(new StorageService());
                }

                if (_apiClient == null) CreateClient();

                tcs.SetResult(true);
            });

            await tcs.Task;
        }